Keyword

Display specific extra field in module position ?

More
11 years 3 weeks ago #103165 by Iannis Camillieri
Replied by Iannis Camillieri on topic Re: Display specific extra field in module position ?
I'm using Joomla 2.5.14 and K2 2.6.7
With that configuration, I should be able to use K2 extrafields aliases with :
$this->item->extraFields->EXTRAFIELDALIASHERE->name
and
$this->item->extraFields->EXTRAFIELDALIASHERE->value
as it is explained here
getk2.org/blog/item/1068-k2-v262-now-available
to display a specific extra field.

Is there a way to use that code in a K2 Tool module (with the personalized code option) so I could display my extra field in a specific location without creating a K2 module sub template?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 weeks ago #103166 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display specific extra field in module position ?
K2 Tools is not intended to display item lists. You need to use K2 Content istead in order use this snippet.

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

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

More
11 years 3 weeks ago #103167 by Iannis Camillieri
Replied by Iannis Camillieri on topic Re: Display specific extra field in module position ?
What I would like to do is to be able to display some K2 item data (like title, main text, image gallery…) in the content location of the page, while displaying some specific data of the same K2 item in other locations of the page using multiple K2 BNR Content modules.
This works fine but I can't choose witch specific extra field to display. With K2 BNR Content module, It's all or none.
I saw that since K2 v2.6.2 there's a way to call a specific extra field using its alias in PHP code ($this->item->extraFields->EXTRAFIELDALIASHERE->name ). But this code seems to be used in a sub template. As I don't know much of PHP language and how to create and use sub templates, I would like to know if there an easier way to use that code in a module.
Thanks for your help.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 weeks ago #103168 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display specific extra field in module position ?
This cannot be done without a K2 Content module.

The code is pretty straight forward (it is a c/p snippet) and you shouldn't have any issues creating a new subtemplate.

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

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

More
10 years 3 months ago #103169 by Joe Campbell
Please provide the "specific" code necessary to display the Extra Field for the item page that user is on.

When I attempt to use the standard code, it renders a blank screen:
<?php echo $this->item->extraFields->ExtraFieldAlias->value; ?>

I also tried using the BNR module - which only shows all extra fields (as mentioned by Iannis Camillieri in a previous post). When I tried using the module, it rendered a blank screen.

What is the "specific" code needed to utilize a K2 Content module to displaying an Extra Field?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 3 months ago #103170 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Display specific extra field in module position ?
This code is not intended for the BNR module.
In the K2 Content module you do not need $this.
<?php echo $item->extraFields->ExtraFieldAlias->value; ?>

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

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

More
10 years 4 weeks ago #103171 by baggiesmad

Krikor Boghossian wrote: This code is not intended for the BNR module.
In the K2 Content module you do not need $this.

<?php echo $item->extraFields->ExtraFieldAlias->value; ?>



Tried the following in my default.php template file but doesnt display anything...

<?php
if (!isset($item->extraFields))
{
$item->extraFields = new stdClass;
}
foreach ($item->extra_fields as $extraField)
{
$tmpAlias = $extraField->alias;
$item->extraFields->$tmpAlias = $extraField;
}
?>


<div class="moduleItemExtraFields"><span class="moduleItemExtraFieldsValue"><?php echo $item->extraFields->JobID->value; ?></span>

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


Powered by Kunena Forum