Keyword

[SOLVED] How to show a few extra fields in category view?

  • theant
  • theant's Avatar Topic Author
  • Offline
  • Premium Member
More
11 years 4 months ago #115776 by theant
Hello
I need to show a few extra fields (not all) in category view. Is it possible to choose which to show and wich not?

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

  • Yiota
  • Yiota's Avatar
  • Visitor
11 years 4 months ago #115777 by Yiota
I'm afraid that you can do that only by code.
You will have to modify the category_item.php in order to fetch specific extra fields.

First of all you have to create K2 overrides, if not already. Read here (getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates) how the overrides work
Then open category_item.php since this is the one you want to show the specific extra fields.
Locate the extra fields block of code and use this code snippet to fetch each extra field
<?php if ($this->item->extraFields->Your_extrafields_alias): 
echo $this->item->extraFields->Your_extrafields_alias->name; 
echo $this->item->extraFields->Your_extrafields_alias->value; 
endif; ?>

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

  • theant
  • theant's Avatar Topic Author
  • Offline
  • Premium Member
More
11 years 4 months ago #115778 by theant
Thanks a lot. I used another way: styling every extrafield and set display: none for extrafield I don't want to show

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


Powered by Kunena Forum