klox7 VIP
Total posts: 914
23 Sep 2014 11:29

Hello,

how to remove specific field from code bellow? Something like this item->fields_by_groups['']['field-key']); ?>

<?php if(isset($this->item->fields_by_groups[null])):?>
    <dl class="dl-horizontal fields-list">
        <?php foreach ($this->item->fields_by_groups[null] as $field_id => $field): ?>
            <dt id="<?php echo 'dt-'.$field_id; ?>" class="<?php echo $field->fieldclass;?>">
                <?php if($field->params->get('core.show_lable') > 1):?>
                    <label id="<?php echo $field->id;?>-lbl">
                        <?php echo $field->label; ?>
                        <?php if($field->params->get('core.icon')):?>
                            <?php echo HTMLFormatHelper::icon($field->params->get('core.icon'));  ?>
                        <?php endif;?>
                    </label>
                    <?php if($field->params->get('core.label_break') > 1):?>
                    <?php endif;?>
                <?php endif;?>
            </dt>
            <dd id="<?php echo 'dd-'.$field_id; ?>" class="<?php echo $field->fieldclass;?><?php echo ($field->params->get('core.label_break') > 1 ? ' line-brk' : NULL) ?>">
                <?php echo $field->result; ?>
            </dd>
        <?php endforeach;?>
    </dl>
    <?php unset($this->item->fields_by_groups[null]);?>
<?php endif;?>

Last Modified: 25 Sep 2014


Jeff VIP
Total posts: 745
24 Sep 2014 03:31

Just place this code before yours, where 1 is the id number of the field you wish to exclude.

<?php unset ($item->fields_by_id[1]->result); ?>

Read also:

http://docs.mintjoomla.com/en/cobalt/custom-templates-article/#q-what-if-i-display-explicitly-only-one-field-and-rest-i-want-to-fetch-and-i-do-not-want-this-field-to-be-listed-in-the-cycle


klox7 VIP
Total posts: 914
24 Sep 2014 06:13

But I tried this... :O. Thank you.


Sergey
Total posts: 13,748
24 Sep 2014 07:44
unset($this->item->fields_by_groups[null][$key])

klox7 VIP
Total posts: 914
24 Sep 2014 13:00

Sergey unset($this->item->fields_by_groups[null][$key])

Better because it removes whole field (label+result).


klox7 VIP
Total posts: 914
24 Sep 2014 18:02

No I have removed fields but now I want to display them elsewhere but combined.

Something like if isset this field or this field and than pass it as variable with implode... or something like that:)

Regards


Sergey
Total posts: 13,748
25 Sep 2014 03:42
$backup = $this->item->fields_by_groups[null][$key];
unset($this->item->fields_by_groups[null][$key])

echo $backup->result;

You delete it from array so it is not listed with cycle and use it separately.

Replay Topic
Uploading
Click here to upload and insert file from you hard drive: (png, gif, jpg, jpeg, zip, txt, rar)
Powered by Cobalt