Keyword

[SOLVED] formatting number in joomla k2 extrafields

  • behzad
  • behzad's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago #124957 by behzad
I want to show an extrafields in k2 component (version : 2.6) of joomla (version :2.5.17) with thousand separator , in Item view and Category view , How can I?

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

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 7 months ago #124958 by Yiota
You can add something like

<?php echo number_format($this->item->extraFields->extrafield-alias->value); ?>

for your extrafield, if you want just one to have this replace the line

<span class="catItemExtraFieldsValue"><?php echo $extraField->value; ?></span>

to this

<span class="catItemExtraFieldsValue"><?php echo number_format($extraField->value); ?></span>

in both category_item.php and item.php files in the foreach element.
Note that your code will break if you put anything but a number in the values of your extra fields.

Also, if you are not using template overrides you need to. Read here getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates how template overrides for K2 work.

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

  • behzad
  • behzad's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 7 months ago #124959 by behzad
Thank you very much...

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


Powered by Kunena Forum