Giorgi625 VIP
Total posts: 655
02 Aug 2018 10:35

I have type which has relation field. This field is shown in full view only. I have added related articles to some records, to others not yet.

In list view I want to somehow let people know which records have related article and which not. How can it be done?

<?php if(isset($item->fields_by_key[$params->get('tmpl_params.field_video')])):?>
    <?php echo $item->fields_by_key[$params->get('tmpl_params.field_video')]->result; ?>            
<?php endif; ?>

This code displays related articles in full view if they exist, if not it does nothing. I want same but as a result want only text "YES" or something constant if value exists if not display nothing.

Just editing second line displays custom text for all records, even if it does not have attached related article.

Last Modified: 03 Aug 2018


Sergey
Total posts: 13,748
03 Aug 2018 04:55

Do

var_dump($item->fields_by_key[$params->get('tmpl_params.field_video')]->result)

And see how many simbols are inside on the item were there is not record. May be you need

<?php if(trim($item->fields_by_key[$params->get('tmpl_params.field_video')]->result)):?>
    <?php echo $item->fields_by_key[$params->get('tmpl_params.field_video')]->result; ?>            
<?php endif; ?>
Powered by Cobalt