[SOLVED] Related field custom output in template and not in the field

2 years 6 months ago - 2 years 5 months ago #57891 by agata
Hello,
The related articles field allows to add custom code to the field's configuration which works fine in most cases but unfortunately doesn't allow for any php code within that custom output so I'm wondering if it's possible to load that field and all the field values associated with the items selected in the template.
Any help greatly appreciated.
Thanks,
Agata

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

2 years 6 months ago - 2 years 5 months ago #57896 by ggppdk
Hello

templating is currently implemented in 2 fields:
- International address (both item form and item viewing)
- File field (both item form and item viewing)

and via configuration parameter (value via executing PHP code)
- text field


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

2 years 6 months ago #57897 by ggppdk
Here is a new enhancement issue

github.com/FLEXIcontent/flexicontent-cck/issues/323

currently this is of low priority


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

2 years 6 months ago #57898 by agata
So it's not possible to create a foreach loop and load the values associated with the field? Like with for example the images?
I don't want to create templates for the field, I need to load a specific related field in my item.php but with a custom structure.
Agata

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

2 years 6 months ago - 2 years 6 months ago #57903 by ggppdk
Hello

you have the field values of the related fields in
$my_rels_field_ID = 555;
print_r($item->fieldvalues[$my_rels_field_ID]);

you can try to call item model and load the item and then display it
(see our FAQ for loading an item)
www.flexicontent.org/documentation/faq/7...-in-custom-code.html


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!
The following user(s) said Thank You: agata

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

2 years 6 months ago - 2 years 6 months ago #57917 by agata
Hi, thanks, I came up with the code below in case anybody needs something similar
<?php $field_dest_featured_highlight = 81;
    function get_article_id($string) {
      return explode(":", $string)[0];
    }
    $articleid = array_map("get_article_id", $this->item->fieldvalues[$field_dest_featured_highlight] );
    $item_arr = $articleid;
    $itemmodel_name = FLEXI_J16GE ? 'FlexicontentModelItem' : 'FlexicontentModelItems';
    $itemmodel = new $itemmodel_name();
    foreach( $item_arr as $item_id ) {
        $item = $itemmodel->getItem($item_id, $check_view_access=false);
        $item_link = JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug));
        $items = array(&$item);
        FlexicontentFields::getFields($items);
        FlexicontentFields::getFieldDisplay($item, 'title');
        $title = $item->title;
        FlexicontentFields::getFieldDisplay($item, 'field_thumb');
        $thumb = $item->fields['field_thumb']->{'display_large_src'};
        FlexicontentFields::getFieldDisplay($item, 'field_oneliner');
        $oneliner = $item->fields['field_oneliner']->display;
        echo '<div class="layout__item layout__item--flex 1/3 palm-1/1  palm--hidden">
        <div class="cards__item">
        <div class="cards__cover">
        <div class="cards__image" style="background-image:url('.$thumb.')"></div>
        </div>
        <div class="cards__description">
        <h3 class="cards__heading">'.$title.'</h3>
        <p class="cards__body">'.$oneliner.'</p>
        <a href="'.$this->fields['field_dest_viewall_highlights']->display.'" class="font--brand link--more">Read more</a>
        </div>
        </div>
        </div>';
    }
                                ?>

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

2 years 4 months ago #59102 by agata
Hi again,
Is there a way to have the items in the code above to be in the order set within the field? They display alphabetically no matter what I set in the field and I need them in the order set in current category.
Thanks,
Agata

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

2 years 4 months ago #59163 by ggppdk
Hello

if you mean order of items inside the relation field
- we added support for all ordering that were ignored in

v3.0.10
github.com/FLEXIcontent/flexicontent-cck/releases


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

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

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.