Page 1 of 1

[solved] News {If then else} Statement not working in v1.11

Posted: Sat Aug 11, 2012 11:47 am
by hanover
Hi
I want to replace main news title with a custom title2 if exist. As per C Arasmo's solution my code is shown below. But the news module is not showing the main news title when title2 is empty. It would be nice if someone give me a working solution. Thank you.

Code: Select all

{foreach from=$items item=entry}

{if $entry->fieldsbyname.title2 != ''}

{$entry->fieldsbyname.title2->value}

{else}

{$entry->title|cms_escape}

{/if}

{/foreach}

I tried another way, but this one also not working.

Code: Select all

{foreach from=$items item=entry}

{if $entry->fieldsbyname.title2 != ''}

{$entry->fieldsbyname.title2->value}

{else if $entry->fieldsbyname.title2 == ''}

{$entry->title|cms_escape}

{/if}

{/foreach}

Re: News {If then else} Statement not working in v1.11

Posted: Sat Aug 11, 2012 11:57 am
by Jean le Chauve
{foreach from=$entry->fields item='field'}
{if $field->name == 'title2' && $field->value neq ''}
{$entry->value}
{else}...

Re: News {If then else} Statement not working in v1.11

Posted: Sat Aug 11, 2012 1:47 pm
by hanover
Hi Jean le Chauve, thank you so much for taking time to reply me unfortunately your code did not work.

but Zenojl's http://forum.cmsmadesimple.org/viewtopi ... =3&t=62271 post provided a clear solution.

Code: Select all

{if $entry->fields.title2->value}

{$entry->fields.title2->value} 

{else}
 
{$entry->title|cms_escape} 
{/if}