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

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
hanover
Forum Members
Forum Members
Posts: 14
Joined: Fri Jul 13, 2012 8:26 am

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

Post 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}
Last edited by hanover on Sat Aug 11, 2012 1:51 pm, edited 1 time in total.
Jean le Chauve

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

Post by Jean le Chauve »

{foreach from=$entry->fields item='field'}
{if $field->name == 'title2' && $field->value neq ''}
{$entry->value}
{else}...
hanover
Forum Members
Forum Members
Posts: 14
Joined: Fri Jul 13, 2012 8:26 am

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

Post 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}
Locked

Return to “[locked] Installation, Setup and Upgrade”