Keyword

Extra fields of related items not available!

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar Topic Author
  • Offline
  • Platinum Member
  • Joomla Developer
More
9 years 7 months ago - 9 years 7 months ago #140751 by Mohamed Abdelaziz
Extra fields of related items not available! was created by Mohamed Abdelaziz
Hi All,

More than a year ago, I wrote a small tutorial for how to make it possible to display extra fields of related items in the related items section, by hacking components/com_k2/models/itemlist.php, you can read it here: www.joomreem.com/joomla-developer-s-tips-and-tricks/item/51-how-to-show-extra-fields-for-k2-related-items.html

Then, I received a suggestion to convert this hack into a plugin, which is very interesting to me, after I started to develop this plugin, I found it is very easy to include this feature in core K2, without any more plugins.

I will be happy if K2 developers agreed to include this small hack in a coming release, just in case K2 community needs it.

The simple solution is just to modify components/com_k2/models/item.php, replace the below code, line ~181:
//Extra fields
if (($view == 'item' && $item->params->get('itemExtraFields')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemExtraFields')) || ($view == 'itemlist' && $task == 'tag' && $item->params->get('tagItemExtraFields')) || ($view == 'itemlist' && ($task == 'search' || $task == 'date') && $item->params->get('genericItemExtraFields')))
{
	$item->extra_fields = $this->getItemExtraFields($item->extra_fields, $item);
}

With the following:
//Extra fields
if ((($view == 'item' || $view == 'relatedByTag')  && $item->params->get('itemExtraFields')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemExtraFields')) || ($view == 'itemlist' && $task == 'tag' && $item->params->get('tagItemExtraFields')) || ($view == 'itemlist' && ($task == 'search' || $task == 'date') && $item->params->get('genericItemExtraFields')))
{
	$item->extra_fields = $this->getItemExtraFields($item->extra_fields, $item);
}

So, it is just ORing $view == 'relatedByTag' to allow getting extra fields of related items.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store
Last edit: 9 years 7 months ago by Mohamed Abdelaziz.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 7 months ago #140765 by Krikor Boghossian
Replied by Krikor Boghossian on topic Extra fields of related items not available!
Hello Mohamed,

You can create a PR here github.com/joomlaworks/k2 :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar Topic Author
  • Offline
  • Platinum Member
  • Joomla Developer
More
9 years 7 months ago #140938 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Extra fields of related items not available!
I have created one and it is merged, thanks Krikor!

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.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 7 months ago #140953 by Krikor Boghossian
Replied by Krikor Boghossian on topic Extra fields of related items not available!
You 're welcome :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
8 years 11 months ago #148716 by Joe Campbell
Replied by Joe Campbell on topic Extra fields of related items not available!
Has this been added to 2.7 or 3?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 11 months ago #148722 by Krikor Boghossian
Replied by Krikor Boghossian on topic Extra fields of related items not available!
Everything in this repo is 2.7

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum