- Posts: 44
COMMUNITY FORUM
Display an extraField in a module
- yannick berges
-
Topic Author
- Offline
- Senior Member
my goal is :
- user can manage image in item
- image is display in module position for better styling
thanks for any help
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Furthermore the edit button is only available in the component.
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
- Posts: 438
Please Log in or Create an account to join the conversation.
- Nazmal Hossain
-
- Offline
- New Member
- Posts: 9
<?php
$k2obj = new K2ModelItem();
$fields = $k2obj->getItemExtraFields($item->extra_fields, $item);
?>
<?php if($item->extraFields->TitleOne->value!='') {?>
<span class="title"><?php echo $item->extraFields->TitleOne->value; ?></span>
<?php } ?>
Here TitleOne is the alias of k2 extra field.
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
- Posts: 438
Please Log in or Create an account to join the conversation.
- Nazmal Hossain
-
- Offline
- New Member
- Posts: 9
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
- Posts: 438
This is how I tried to implement it.
Please Log in or Create an account to join the conversation.
- Nazmal Hossain
-
- Offline
- New Member
- Posts: 9
templates/loanton/html/mod_k2_content/Default/default.php
Please make sure that, from backend k2 content module area, you have selected extra field show [yes]
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
- Posts: 438
I even added plain text in the override module.
The plain text displays, but the extra field does not.
Please provide the code for the entire override file.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Keep in mind where $this->item and $item is being used.
Enable extrafields, use that code and comment out the loop which prints all extrafields (if you don't need them).
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
- Posts: 438
Please test first — thanks
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
- Posts: 438
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
I think the K2 BNR Content module can be used for this purpose.
Either by using template overrides for the module, i.e to create a separate template override for each extra field you want to show, you need to replace the section of extra fields display of the module to show only one extra field by alias, then to select that template override in the proper module instance.
Or, by hacking the module to add a text field parameter to enter the field alias you want to show with this module instance.
This is a quick tutorial on how to display K2 extra field of the current item in a module position using BNR Content for K2
Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
Can you please clarify what exactly do you mean by "the current item"?
K2 content module cannot fetch the data of the current item page if this is what you mean.
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
- Posts: 438
I wonder how/why @Nazmal is saying he can do it...
www.joomlaworks.net/forum/k2-en/47520-display-an-extrafield-in-a-module?limitstart=0#160860
It would be ideal if the K2 Content Module could do it
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
- Posts: 8743
This is about displaying a specific extra field of the items fetched by the K2 content module (depending on the module settings) .
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
- Posts: 438
Please Log in or Create an account to join the conversation.
- Joe Campbell
-
- Offline
- Platinum Member
- Posts: 438
Note: if you not need apply conditions and just want to display extra fields of the current item, you can always uses the trusty Regular Labs Articles Anywhere extension with following code. Simply change the extra field ID:
{article k2:current}{extra-198}{/article}
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.