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

More
9 years 1 month ago - 9 years 4 weeks 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
Last edit: 9 years 4 weeks ago by ggppdk.

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

More
9 years 1 month ago - 9 years 4 weeks 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...
Last edit: 9 years 4 weeks ago by ggppdk.

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

More
9 years 1 month 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...

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

More
9 years 1 month 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.

More
9 years 1 month ago - 9 years 1 month ago #57903 by ggppdk
Hello

you have the field values of the related fields in
Code:
$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...
Last edit: 9 years 1 month ago by ggppdk.
The following user(s) said Thank You: agata

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

More
9 years 1 month ago - 9 years 1 month ago #57917 by agata
Hi, thanks, I came up with the code below in case anybody needs something similar
Code:
<?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>'; } ?>
Last edit: 9 years 1 month ago by agata.

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.450 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