- Posts: 69
COMMUNITY FORUM
[SOLVED] How to show extra fields for related items
- Uldis
- Topic Author
- Offline
- Senior Member
Less
More
11 years 6 months ago - 11 years 6 months ago #113070
by Uldis
[SOLVED] How to show extra fields for related items was created 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?
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
- Offline
- Platinum Member
Less
More
- Posts: 15920
11 years 6 months ago #113071
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
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.
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
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 69
11 years 6 months ago #113072
by Uldis
Replied by Uldis on topic Re: How to show extra fields for related items
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
It just doesn't work with extra fields :(
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.
- BBC
- Offline
- Platinum Member
Less
More
- Posts: 663
11 years 5 months ago #113073
by BBC
Replied by BBC on topic Re: How to show extra fields for related items
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
- Offline
- Platinum Member
- Joomla Developer
11 years 5 months ago #113074
by Mohamed Abdelaziz
Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store
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:after this line:
This way, you can useto show extra fields for related items.
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]);
$rows[$key] = $model->execPlugins($rows[$key], 'relatedByTag', '');
This way, you can use
<?php echo $item->extraFields->EXTRAFIELDALIASHERE->value; ?>
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.
- Yanick
- Offline
- New Member
Less
More
- Posts: 9
11 years 2 months ago #113075
by Yanick
Replied by Yanick on topic Re: How to show extra fields for related items
Thanks Mohamed!
This really needs to be default in K2.
This really needs to be default in K2.
Please Log in or Create an account to join the conversation.
- moni
- Offline
- New Member
Less
More
- Posts: 11
11 years 19 hours ago #113076
by moni
Replied by moni on topic Re: How to show extra fields for related items
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
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
- Offline
- Platinum Member
- Joomla Developer
11 years 14 hours ago #113077
by Mohamed Abdelaziz
Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store
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
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.
- Kenneth Chee
- Offline
- New Member
Less
More
- Posts: 1
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?
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
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 1 month ago #113079
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
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
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.