Keyword

How to display specific extra field in a Tag Page

  • Steven Johnson
  • Steven Johnson's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 7 months ago #110640 by Steven Johnson
I am able to display specific fields in my item and category page but it is not working for the Tag Page.

Here is what I am using

At top of page:

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

  • Andrey Miasoedov
  • Andrey Miasoedov's Avatar
  • Offline
  • Senior Member
More
11 years 7 months ago #110641 by Andrey Miasoedov
Replied by Andrey Miasoedov on topic Re: How to display specific extra field in a Tag Page
Hello, Steven.

You need to use your extra code not at top of page but after <?php foreach($this->items as $item): ?> code in tag.php template file. And also you need to replace $this->item with $item and use another variable name for extrafield, e.g.:
Log in  or Create an account to join the conversation.

  • Steven Johnson
  • Steven Johnson's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 6 months ago #110642 by Steven Johnson
Replied by Steven Johnson on topic Re: How to display specific extra field in a Tag Page
Thanks so much for the reply and info.

I was able to get and extra field to display using this extra code
Log in  or Create an account to join the conversation.

  • Steven Johnson
  • Steven Johnson's Avatar Topic Author
  • Offline
  • Senior Member
More
11 years 5 months ago - 11 years 5 months ago #110643 by Steven Johnson
Replied by Steven Johnson on topic Re: How to display specific extra field in a Tag Page
For those who are interested in using the newer method to display an extrafield on the tag page, a hack to one of the core files (as of K2 2.6.6) Here is what I did:


Add some extra code to components\com_k2\models\item.php

Add || $task == "tag" to extrafields condition (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')) || $task == "tag")

Use the following syntax to display the extra field
<?php echo $item->extraFields->fieldAlias->name; ?>
<?php echo $item->extraFields->fieldAlias->value; ?>

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

  • ATHANASIOS ILIOPOULOS
  • ATHANASIOS ILIOPOULOS's Avatar
  • Offline
  • Senior Member
More
11 years 5 months ago #110644 by ATHANASIOS ILIOPOULOS
Replied by ATHANASIOS ILIOPOULOS on topic Re: How to display specific extra field in a Tag Page
Thanks Steven for this really useful hack..

I am wondering if there is any way of adding intro text per tag listing (menu item - k2 tags) ... I think this is not possible, eh? :)

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