Keyword

Display an extraField in a module

  • yannick berges
  • yannick berges's Avatar Topic Author
  • Offline
  • Senior Member
More
8 years 3 months ago #160809 by yannick berges
Display an extraField in a module was created by yannick berges
hello i want to display an extrafield in module like a custom html module (with sourcer) or other solution
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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 3 months ago #160816 by Krikor Boghossian
Replied by Krikor Boghossian on topic Display an extraField in a module
You can use the K2 Content module to display the extrafields although you can style them any way you want in the component as well.

Furthermore the edit button is only available in the component.

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

More
8 years 2 months ago #160854 by Joe Campbell
Replied by Joe Campbell on topic Display an extraField in a module
Hi @Krikor please provide the K2 Content Module override code for only displaying a specific extra field.

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

More
8 years 2 months ago #160860 by Nazmal Hossain
Replied by Nazmal Hossain on topic Display an extraField in a module
If you want to display specific extra field then you can use like this below code

<?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.

More
8 years 2 months ago #160861 by Joe Campbell
Replied by Joe Campbell on topic Display an extraField in a module
Thanks Nazmal - but this does not work

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

More
8 years 2 months ago #160863 by Nazmal Hossain
Replied by Nazmal Hossain on topic Display an extraField in a module
Code I posted on previous email working many of my sites. Please check carefully. May be you not working on correct file. Or you are not writing extrafield alias. Or missing something else. But it should work correctly.

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

More
8 years 2 months ago #160864 by Joe Campbell
Replied by Joe Campbell on topic Display an extraField in a module
You have used it to produce a K2 Content Module (override)?

This is how I tried to implement it.

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

More
8 years 2 months ago #160865 by Nazmal Hossain
Replied by Nazmal Hossain on topic Display an extraField in a module
Yes template overwrite. Say my template name is loanton. Then file will stay in

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.

More
8 years 2 months ago #160867 by Joe Campbell
Replied by Joe Campbell on topic Display an extraField in a module
The extra field parameter is set to "Show"

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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #160869 by Krikor Boghossian
Replied by Krikor Boghossian on topic Display an extraField in a module
It's the same as the component check the usual repo :).
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.

More
8 years 2 months ago #160871 by Joe Campbell
Replied by Joe Campbell on topic Display an extraField in a module
I would,greatly appreciate if someone provided the code for the entire file.

Please test first — thanks

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #160875 by Krikor Boghossian
Replied by Krikor Boghossian on topic Display an extraField in a module
Why not use K2 Content and only display the extrafields?

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

More
8 years 2 months ago #160879 by Joe Campbell
Replied by Joe Campbell on topic Display an extraField in a module
My goal is to render an extra field from the current item into a module.

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
8 years 2 months ago - 8 years 2 months ago #160887 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Display an extraField in a module
Hi All,

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
Last edit: 8 years 2 months ago by Mohamed Abdelaziz. Reason: Added reference of the tutorial

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

More
8 years 2 months ago #160914 by Lefteris
Replied by Lefteris on topic Display an extraField in a module
@Joe Campbell

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.

More
8 years 2 months ago - 8 years 2 months ago #160915 by Joe Campbell
Replied by Joe Campbell on topic Display an extraField in a module
Thanks @Lefteris

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
Last edit: 8 years 2 months ago by Joe Campbell.

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

More
8 years 2 months ago #160916 by Lefteris
Replied by Lefteris on topic Display an extraField in a module
@Joe Campbell

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.

More
8 years 2 months ago #160917 by Joe Campbell
Replied by Joe Campbell on topic Display an extraField in a module
Can the K2 Content Module fetch the extra field JSON for the current page?

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

More
8 years 2 months ago #160918 by Joe Campbell
Replied by Joe Campbell on topic Display an extraField in a module
Now that I heard from @Lefteris that it can not be accomplished with the core K2 Content Module, I installed BNR Content for K2 and created an override — it works like a charm.

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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 2 months ago #160961 by Krikor Boghossian
Replied by Krikor Boghossian on topic Display an extraField in a module
Kudos buddy :)

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


Powered by Kunena Forum