News module: "File" field definition not working with {if}
Posted: Thu Sep 08, 2011 7:09 pm
Hello,
I wanted an image associated with each news post, so I added a new field definition called "summaryImage".
On my summary template, I created an if statement, that if there is no "summaryImage" uploaded, then show a default image. But i cant get it to work. I can see the uploaded image, but do not get the default image.
Here is my code for the summary template:
So basically, from above, the "SHOW DEFAULT IMAGE" is not appearing. Is my logic wrong? Am I going about this the wrong way?
Thanks,
JC
I wanted an image associated with each news post, so I added a new field definition called "summaryImage".
On my summary template, I created an if statement, that if there is no "summaryImage" uploaded, then show a default image. But i cant get it to work. I can see the uploaded image, but do not get the default image.
Here is my code for the summary template:
Code: Select all
<!-- Start News Display Template -->
{foreach from=$items item=entry}
<div class="NewsSummary">
<div class="NewsSummaryLink">
{$entry->titlelink}
</div>
{if isset($entry->fields)}
{foreach from=$entry->fields item='field'}
<div class="NewsSummaryField">
{if $field->type == 'file'}
{if $field->value != ''}
<img src="{$entry->file_location}/{$field->value}"/>
{else}
SHOW DEFAULT IMAGE
{/if}
{else}
{$field->name}: {eval var=$field->value}
{/if}
</div>
{/foreach}
{/if}
</div>
{/foreach}
<!-- End News Display Template -->
Thanks,
JC