Keyword

[SOLVED] How to show extra fields for related items

  • Uldis
  • Uldis's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 6 months ago - 11 years 6 months ago #113070 by Uldis
Hello,

I'm really loving new K2 feature <?php echo $this->item->extraFields->EXTRAFIELDALIASHERE->value; ?>

It has helped me a lot in last few projects.

Unfortunately I can't figure out how to use do this for related items in item view.

I added <?php echo $this->item->extraFields->EXTRAFIELDALIASHERE->value; ?> inside foreach loop, but with no success :(

I also noticed that related items use $item instead of $this->item in order to output elements. So I tried using <?php echo $item->extraFields->EXTRAFIELDALIASHERE->value; ?>, but I still couldn't output extra fields.

Could you please help?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 6 months ago #113071 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How to show extra fields for related items
Hello Uldis,

I am afraid you cannot extrafields in the related items. I think you should use the K2 content module for this functionality.

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

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

  • Uldis
  • Uldis's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 6 months ago #113072 by Uldis
But If I use k2 content module I can only select specific items or items from category.

I would also need to create new module for each item :(

I really needed related by tag functionality because each items will have different related items.

Is there really no way? Related items by tag can get almost any information using
<?php echo $item->introtext; ?>

It just doesn't work with extra fields :(

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

More
11 years 5 months ago #113073 by BBC
There is no way, as i know it. Only paid modules but they are not what you want. They more or less pull related Items by Tags.

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
11 years 5 months ago #113074 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: How to show extra fields for related items
Hi Uldis,

This can be done by hacking the components/com_k2/models/itemlist.php file, at line: 955
add this line:
$rows[$key]->extra_fields = $model->getItemExtraFields($rows[$key]->extra_fields, $rows[$key]);
after this line:
$rows[$key] = $model->execPlugins($rows[$key], 'relatedByTag', '');

This way, you can use
<?php echo $item->extraFields->EXTRAFIELDALIASHERE->value; ?>
to show extra fields for related items.

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.

More
11 years 2 months ago #113075 by Yanick
Thanks Mohamed!
This really needs to be default in K2.

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

More
11 years 19 hours ago #113076 by moni
hi Mohamed
i trying to use your code and follow your instructions but its not working for me,maybe because im using the line: <?php echo $item->extraFields->EXTRAFIELDALIASHERE->value; ?> in item.php and i need to change "EXTRAFIELDALIASHERE" to something else but what?

i tried insted "EXTRAFIELDALIASHERE" to put the group name and alias of single extra field but its not working for me and no extra fields data.

what i doing wrong?

thanks

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
11 years 14 hours ago #113077 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: How to show extra fields for related items
Hi moni,

EXTRAFIELDALIASHERE should be replaced by the field alias, you can get it from the extra fields manager at the backend.

But in item.php, it should be $this->item->extraFields, not $tiem->extraFields

hope this can help

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.

More
10 years 1 month ago #113078 by Kenneth Chee
Replied by Kenneth Chee on topic Re: How to show extra fields for related items
Hi Mohamed

I was wondering whether it would be possible to take it a step further to show only those Related Items that share a common value in a given extra field.

For example, if 10 items are tagged "Apples", normally the Related items will show all 10 items tagged as "Apples". However, if only 7 of those items that are tagged "Apples" have the value "sour' inserted into an extra field called "Taste", then only those 7 "sour" apples will show up in the Related Items section.

Is that possible to do?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 1 month ago #113079 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: How to show extra fields for related items
This has already been request as a feature in the upcoming version.
You can see the feature requests for the next version here: github.com/joomlaworks/k2-v3-dev-build

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