[SOLVED] Custom field defs. in News Module gone wonky

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
pixelita
Power Poster
Power Poster
Posts: 388
Joined: Sun Sep 16, 2007 3:07 am

[SOLVED] Custom field defs. in News Module gone wonky

Post by pixelita »

I found Goran Ilic's solution for adding images to news articles. Here is my detail template:

Code: Select all

<!-- Detail Template Goran Code -->
{if $entry->formatpostdate}
	<div id="NewsPostDetailDate">
		{$entry->formatpostdate}
	</div>
{/if}
<h3 id="NewsPostDetailTitle">{$entry->title}</h3>

<hr id="NewsPostDetailHorizRule" />

{if $entry->summary}
	<div id="NewsPostDetailSummary">
		<strong>
			{eval var=$entry->summary}
		</strong>
	</div>
{/if}

{if $entry->category}
	<div id="NewsPostDetailCategory">
		{$category_label} {$entry->category}
	</div>
{/if}

<div id="NewsPostDetailContent">


{eval var=$entry->content}
 {foreach from=$items item=entry}
  <div class="newsimage">
{if isset($items[0]->fieldsbyname.newsimage)}
   <img src="{$items[0]->file_location}/{$items[0]->newsimage}"  alt="{$entry->title}" width="525" />
{/if}
   </div>
{/foreach}
</div>

<p><strong>Spread the word!</strong><br />
{socialBookmarking submitto="email|facebook|twitter|linkedin|google|digg|reddit|stumbleupon" real_url="1" }</p>

<p><a href="/news/news-archives">View all news items</a>.<br />
<a href="/news/topics">View news items by category</a>.</p>

My field definition is "newsimage" so I changed Goran's code to reflect that.

The problem is that when I retroactively go back to old news articles to add their appropriate images, it just adds the image from the latest news article, although in the news article edit screen, the correct image is show. So for every news article I revise, I get that exact number of the same images repeating over and over in each article.

Here is a link to the site, click on the sidebar or on the feature boxes to access the news articles:
http://www.idylwood.org

If you view the source code, you'll see it's capturing the correct article, but the wrong image. Also of note, the same article ID is being used for each article and that shouldn't be.

Code: Select all

   <div class="newsimage">
   <img src="http://idylwood.org/uploads/news/id53/storm.png"  alt="Try the City of Houston's New Storm Risk Calculator Website" width="525" />

   </div>
  <div class="newsimage">
   <img src="http://idylwood.org/uploads/news/id53/storm.png"  alt="Early Voting Underway" width="525" />
   </div>
  <div class="newsimage">
   <img src="http://idylwood.org/uploads/news/id53/storm.png"  alt="Water Conservation, 2011" width="525" />
   </div>
Actually, the "Early Voting Underway" article has NO image associated with it.

I am willing to hit someone's PayPal button for help with this.

Thanks!
Last edited by pixelita on Mon Jan 09, 2012 5:10 am, edited 1 time in total.
Submit your site to the We Love CMSMS showcase
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Custom field defs. in News Module gone wonky

Post by Dr.CSS »

I use this, the field definition is image...

<img src="{$entry->file_location}/{$entry->image}" alt="{$entry->title}" />
User avatar
pixelita
Power Poster
Power Poster
Posts: 388
Joined: Sun Sep 16, 2007 3:07 am

Re: Custom field defs. in News Module gone wonky

Post by pixelita »

Nope. That didn't work. It throws ALL the images one after the other on each post. For WHATEVER unknown reason, CMSMS is associating EVERY uploaded image with each and every post. And it puts in weird URLS:
http://idylwood.org/news/53/66/Try-the- ... r-Website/

Notice the /53/66/ on the above URL; and notice other news URLS:
http://idylwood.org/news/49/66/Fruit-Tree-Sale/

Every one of them has the string /66/ in it. Is this part of the problem?

UPDATE: Finally got it to work. I deleted all the ID folders and images CMSMS had created and started over working from the back forward (instead of from the front backward as I had done before), and this is the detail template code that works:

Code: Select all

<div id="NewsPostDetailContent">
	{eval var=$entry->content}
</div>
<div class="newsimage">
<img src="/uploads/news/id{$entry->id}/{$entry->newsimage}" alt="{$entry->title}" width="525" />
</div>
Submit your site to the We Love CMSMS showcase
Post Reply

Return to “Modules/Add-Ons”