Hi guys,
there is so much stir in this topic that I would like to clarify the whole thing the way I understand it.
K2 is content component for Joomla. As such it brings its own handling of certain aspects of output and awesome templating techniques :) Therefore it does not necessary behaves exactly as original content in Joomla. Extra Fields, I think, were originally meant to simply enter some simple "extra" information that can be used in template .php file to user's liking. Extra Field does not necessary holds information that should be outputted DIRECTLY to the browser. It could be counter of some sort, it can be weight, color, age, etc. (value can be used as counter in cycles, path to file, extra configuration...). But also it can hold html code meant for output (ex: room description of hotel in my website).
So the information of what should happen with this Extra Field information is prescribed in .php template file. There is some default behavior which is written in bunch of default templates, for ex. in file:
components/com_k2/templates/default/item.php
However you should never touch this file. Therefore there is perfectly legitimate and advised way of customizing and overwriting this .php template file - which is essential to K2 templating. You can read details about K2 templating here
simon.getk2.org/k2-documents/item/91-templating. Making long story short, for above file there should be this custom file that will handle representation of default item:
templates/YOUR_TEMPLATE/html/com_k2/default/item.php
This is not a hack, this is how it should be done and you are not touching core files, just customizing template.
So basically when you create template from scratch (or just copying and adjusting existing default template), you need to define how those Extra Fields will be handled. By default they are just plainly echoed for browser as name and value pair. See that original item.php file around line 255. However they are not scanned for {plugin} tags, therefore plugins are not recognized.
You can write your own template (or copy and adjust existing). There are basically 2 aproaches that come to my mind. Both will require to adjust for ex. this file
templates/YOUR_TEMPLATE/html/com_k2/default/item.php
and of course that template must be activated in Joomla backend. You do not have to build whole new template, neither your template will have to have all the template files, it is enough to copy and adjust just single file, rest of the template will automagically use default template provided by K2. So finaly here are two snipets that could be used in item.php custom template file:
1) Output all the extra fields in the same fashion as it was main content (example lacks any extra html formating):
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?> <?php echo JHTML::_('content.prepare', $extraField->value); ?><?php endforeach; ?>
In this case you can write in any extra field html + any plugin with its crazy parameters and it will be outputed as expected. So you can enter in backend's extrafield something like this:
This is my gallery.
{gallery rows=3 cols=1 width=200 height=140 crop=1 labels=captions alignment=left orientation=horizontal buttons=0 links=0 counter=0 overlay=1}stories/brasil/{/gallery}
Pictures are showing my vacation in Brasil :)
2) There could be numerous cases when you decide that extrafield will hold just partial info (like path to the gallery). ex: first extrafield will be gallery description, second field path, etc. you get the idea:
$galleryDesc = $this->item->extra_fields[1]->value $galleryPath = $this->item->extra_fields[2]->value
$galleryDesc .'<br />'
echo JHTML::_('content.prepare', '{gallery}' .
So the difference is in designers mind. You just have to know what to expect in Extra Fields and prepare content according. then in .php template file put all the pieces together as you like.
This was exhausting post :)
PS: there couold be some syntax mishap, I did not test it, but sure the idea is right.