If "A" is there, than echo "1" or echo "2" if "1" is empty

More
13 years 9 months ago #13629 by Janiba
Hi,

this is the original code from templates/default/category_items.php
Code:
<!-- BOF item title --> <th scope="row" class="table-titles"> <?php if ($this->params->get('link_titles', 0)) : ?> [url=<?php echo JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $this->category->slug)); ?>]<?php echo $this->escape($item->title); ?>[/url] <?php else : echo $this->escape($item->title); endif; ?> </th> <!-- BOF item title -->
I made this change into my templates/german/category_items.php
Code:
<!-- BOF item title --> <th scope="row" class="table-titles"> <?php if ($this->params->get('link_titles', 0)) : ?> [url=<?php echo JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $this->category->slug)); ?>&tab=German]<?php echo($item->fields['germantitle']->display); ?>[/url] <?php else : echo $this->escape($item->title); endif; ?> </th> <!-- BOF item title -->
and it works great.
I would like to extend this, that if there is a case that the field ist empty the field should be used.

something like:
Code:
<?php echo(empty($item->fields['germantitle'])) ? ($item->fields['title']->display) : ($item->fields['germantitle']->display); ?>
but my php knowledge is less than poor! please help! Thank you! :roll:

Please Log in or Create an account to join the conversation.

More
13 years 8 months ago #14088 by kath
maybe this helps you (untested)

<?= ($item->fields->display!='')
? ($item->fields->display)
: ($item->fields->display);
?>

kath

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.950 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline