• Sign In
    • Forgot your password?
    • Forgot your username?

K2 | The powerful content extension for Joomla! developed by JoomlaWorks

  • home
  • about
  • blog
  • documentation
  • extend K2
  • showcase
  • community
  • demo
K2 brings the good parts from WordPress & Drupal into Joomla
You are heredocumentation Tips & Tricks Display single extra fields anywhere in your K2 content

Display single extra fields anywhere in your K2 content

31 March 2019, 17:07 by Fotis Evangelou
in Tips & Tricks
  • Print/PDF

To directly output individual extra fields in your K2 overrides, do something like this (e.g. in item.php) to get the extra field name:

echo $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->name;

To get the extra field value you would simply do this: 
echo $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->value;
echo $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->rawValue; // for date type only

Simply replace EXTRAFIELD_ALIAS_HERE with the actual alias of the extra field you wish to output.

In modules, use:
echo $item->extraFields->EXTRAFIELD_ALIAS_HERE->value;
echo $item->extraFields->EXTRAFIELD_ALIAS_HERE->rawValue; // for date type only

Tags:

  • extra fields
Tweet
  • Contact us
  • Privacy Policy
  • License
  • K2 Downloads
  • K2 Metrics
  • K2 on GitHub
back to top
Copyright © 2006 - 2025 JoomlaWorks Ltd. All rights reserved. K2 is a joint project by JoomlaWorks & Nuevvo, released under the GNU/GPL license.
Joomla is a registered trademark of Open Source Matters, Inc. K2 is not affiliated with or endorsed by Open Source Matters or the Joomla Project.
designed by Nuevvo