Page 1 of 1

broken image icon in news module if no image is uploaded

Posted: Thu Sep 04, 2014 5:37 pm
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 -->

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

Posted: Thu Sep 04, 2014 5:49 pm
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..?

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

Posted: Thu Sep 04, 2014 6:21 pm
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.

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

Posted: Thu Sep 04, 2014 9:41 pm
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

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

Posted: Fri Sep 05, 2014 7:02 pm
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!