News module: "File" field definition not working with {if}

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
joecannes
Forum Members
Forum Members
Posts: 93
Joined: Mon Nov 26, 2007 5:00 pm
Location: Montreal, Quebec

News module: "File" field definition not working with {if}

Post by joecannes »

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:

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}:&nbsp;{eval var=$field->value}
        {/if}
     </div>
  {/foreach}
{/if}


</div>
{/foreach}
<!-- End News Display 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
joecannes
Forum Members
Forum Members
Posts: 93
Joined: Mon Nov 26, 2007 5:00 pm
Location: Montreal, Quebec

Re: News module: "File" field definition not working with {i

Post by joecannes »

This is the main part of the above code that I am a problem with:

Code: Select all


{if $field->value != ''}
<img src="{$entry->file_location}/{$field->value}"/>
{else}
SHOW DEFAULT IMAGE
        {/if}

JC
Post Reply

Return to “Modules/Add-Ons”