klox7 VIP
Total posts: 914
29 Янв 2015 17:54

Hi,

I'm using universal custom template for record list with custom parameters. With custom parameter I'm selecting field in template configuration.

Those fields are only in Type1 but I want be able to select them in every section (types are connected with relation parent-child).

For output I'm using this

<?php
$field_custom = $this->fields_keys_by_id[$params->get('tmpl_params.field_customn')];
if(!empty($item->fields_by_key[$field_custom])):
$custom = $item->fields_by_key[$field_custom];
?>
    <?php echo sprintf('<b>%s:</b> %s', $custom->label, $custom->result); ?>
<?php endif; ?>

This works if I select field within same type/section but it does not work if I select field from Type1 in template settings for Section2.

So if I'm in Section2 (Type2) and go to record list template configuration and I select this field from Type1 I get error.

How can I rebuild upper code so it will work for every section?

Regards

Последние изменения: 04 Фев 2015


Sergey
Total posts: 13,748
30 Янв 2015 02:42

In every section it may be configured differently. In one section you select one field as a parameter in other section you select another field and it works for any section.

I do not know may be this is an error you have n in field_customn.

Apart from that your code looks universal.


klox7 VIP
Total posts: 914
30 Янв 2015 07:43

Sergey In one section you select one field as a parameter in other section you select another field and it works for any section.

To pharaphrase what I'm looking for

In one section you select one field as a parameter in other section you select SAME (from other section) field and it works for any section.


Sergey
Total posts: 13,748
04 Фев 2015 02:14

Tell me what var_dump($params->get('tmpl_params.field_customn')) shows?

Работает на Cobalt