broken image icon in news module if no image is uploaded

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
echobrin
Forum Members
Forum Members
Posts: 54
Joined: Sat May 29, 2010 6:03 pm

broken image icon in news module if no image is uploaded

Post by echobrin »

I'm using the news module to display individual animals. All of the animals have descriptions, but not all of them have photos. For the ones that do NOT have a photo, I'm getting a broken image icon. How can I get rid of this broken image icon?

Here's the link:
http://173.192.209.198/~welshans/index. ... enior-does

And here is the summary template I'm using:

Code: Select all

<!-- Start News Display Template -->


{* this displays the category name if you're browsing by category *}
{if $category_name}
<h1>{$category_name}</h1>
{/if}

{* if you don't want category browsing on your summary page, remove this line and everything above it *}

{if $pagecount > 1}
  <p>
{if $pagenumber > 1}
{$firstpage}&nbsp;{$prevpage}&nbsp;
{/if}
{$pagetext}&nbsp;{$pagenumber}&nbsp;{$oftext}&nbsp;{$pagecount}
{if $pagenumber < $pagecount}
&nbsp;{$nextpage}&nbsp;{$lastpage}
{/if}
</p>
{/if}
{foreach from=$items item=entry}
<div class="NewsSummary">



<div class="NewsSummaryLink">
<h2>{$entry->title|cms_escape}</a></h2>
</div>



<table>
<tr>
<td>
{if $entry->summary}
	<div class="NewsSummarySummary">
		{eval var=$entry->summary}
	</div>

{else if $entry->content}
	<div class="NewsSummaryContent">
		{eval var=$entry->content}
	</div>
{/if}
</td>
<td>
{if isset($entry->extra)}
    <div class="NewsSummaryExtra">
        {eval var=$entry->extra}
	{* {cms_module module='Uploads' mode='simpleurl' upload_id=$entry->extravalue} *}
    </div>
{/if}
{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="NewsSummaryField">
        {if $field->type == 'file'}
          <img src="{$entry->file_location}/{$field->displayvalue}"/>
        {else}
          {$field->name}:&nbsp;{eval var=$field->displayvalue}
        {/if}
     </div>
  {/foreach}
{/if}
</td>
</tr>
</table>
{if $entry->summary}
<div class="NewsSummaryMorelink">
		[{$entry->morelink}]
	</div>
{/if}
</div>
<hr width=80%>
{/foreach}
{if $pagecount > 1}
  <p>
{if $pagenumber > 1}
{$firstpage}&nbsp;{$prevpage}&nbsp;
{/if}
{$pagetext}&nbsp;{$pagenumber}&nbsp;{$oftext}&nbsp;{$pagecount}
{if $pagenumber < $pagecount}
&nbsp;{$nextpage}&nbsp;{$lastpage}
{/if}
</p>
{/if}
<!-- End News Display Template -->
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: broken image icon in news module if no image is uploaded

Post by Dr.CSS »

You must have fixed this as I don't see any broken image links on page nor in page source, where were you adding or not adding them..?
echobrin
Forum Members
Forum Members
Posts: 54
Joined: Sat May 29, 2010 6:03 pm

Re: broken image icon in news module if no image is uploaded

Post by echobrin »

Here's a screenshot.
broken-image.png
The first goat, Lil Pea, does NOT have an image associated with it, and there is a broken image icon to the right of the description.

The second goat, Magic, has an image that is displayed in that location.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1973
Joined: Mon Jan 29, 2007 4:47 pm

Re: broken image icon in news module if no image is uploaded

Post by Jo Morg »

echobrin wrote: For the ones that do NOT have a photo, I'm getting a broken image icon. How can I get rid of this broken image icon?
You need to search a bit, as this is basic Smarty logic:
http://www.smarty.net/docs/en/language.function.if.tpl

Code: Select all

{* ... *}
{if isset($entry->fields)}
  {foreach from=$entry->fields item='field'}
     <div class="NewsSummaryField">
        {if $field->type == 'file'}
           {if !empty($field->displayvalue)}
             <img src="{$entry->file_location}/{$field->displayvalue}"/>
           {/if}
        {else}
          {$field->name}:&nbsp;{eval var=$field->displayvalue}
        {/if}
     </div>
  {/foreach}
{/if}
{* ... *}
 
This bit should work, replacing the {if isset($entry->fields)}....{/if} bit you already have.
HTH
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
echobrin
Forum Members
Forum Members
Posts: 54
Joined: Sat May 29, 2010 6:03 pm

[SOLVED]broken image icon in news module if no image is uplo

Post by echobrin »

Thanks! I got this working with your suggestion, with one change -

Code: Select all

{if !empty($field->fieldvalue)}
to

Code: Select all

{if !empty($field->value)}
Thanks for your help!
Post Reply

Return to “CMSMS Core”