Keyword

Display K2 extra field outside of a K2 item

More
10 years 8 months ago #123416 by Mike
Hey guys, i'm new to Joomla and am mostly a front end developer / designer. I modify php and such with wordpress, but don't write it.

On my joomla site, I've found where k2 extra fields display in the item.php file, but i'd like the extra field to display elsewhere on the site. (outside of that k2 item)

From what i can gather (someone else developed it), the site is on the zen grid framework. I would like the extra field of a k2 item to show on the side bar of my site. I can edit the code where the sidebar is generated in a file found at plugins/system/zengridframework/zengridframework/index.php

However, i have NO idea how to insert php code that might look for the extra field associated with the k2 item that is being displayed in the main section of my website.

www.utahsymphony.org/tickets/952-subscriptions

This is the page. The "Subscriptions" page is the k2 item, the extra field is at the bottom of the page, but i'd like it displaying above where it says "in this section..."

Ask me questions, i'm sure there's tons i don't understand that i should be telling you. THanks in advance.

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

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 8 months ago #123417 by Yiota
Hello Mike,

One way your extrafields can show there is with the use of another module.

There is always the option to completely reconstruct your site's structure for item pages, setup a big gab on the sidebar and then with the proper modification of the item.php page of K2 (you will have to use K2 overrides, read here: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates) you can move the extrafields block on top and with some styling move them in the right place, on the left gab you have created.

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

More
10 years 8 months ago #123418 by Mike
Thanks for the response!

Would you mind showing me an example of how you would show that extra field in another module?

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

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 8 months ago #123419 by Yiota
Ok. Let's say that your extra field's alias is "test" and you need to show it in a mod_k2_content module pointing to a specific item.

You will fetch this specific extrafield with this code:
<?php echo $item->extraFields->test->value; ?>

Make sure to enable extrafields in the module settings.

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


Powered by Kunena Forum