Page 1 of 1

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

Posted: Mon Jan 09, 2012 2:12 am
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!

Re: Custom field defs. in News Module gone wonky

Posted: Mon Jan 09, 2012 3:36 am
by Dr.CSS
I use this, the field definition is image...

<img src="{$entry->file_location}/{$entry->image}" alt="{$entry->title}" />

Re: Custom field defs. in News Module gone wonky

Posted: Mon Jan 09, 2012 4:58 am
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>