Any users of K2 may be familiar with creating template over rides, the art of modifying the styling, operation and layout of different K2 views using a K2 template placed in the Joomla template.
For the last couple of years, I have been providing templates, training and customisation of these views and now that V2.5 of K2 is out, there are a couple of considerations to take into account if your creating your own.
Most view customisation continues to use the standard MVC over ride philosophy, except for the tag view to a certain extent.
What is a tag?
A tag is a way of linking content, items, which can be across a variety of categories.
Imagine your selling electrical items on your site, you can use tags in items such as TV, DVD Player, PLASMA, LCD etc etc.
With the related tags links in K2, an item can not only display the tags that have been set, but also items that have the same tag, even from different categories. More information on how to use this will be covered in a future guide.
Ordinarily, a K2 template over ride can be selected from within the category parameter.
These templates can be either in the component (not recommended) or in the Joomla template (recommended).
You can also select a K2 template via a K2 menu link, more on this later.
A tag can link items from different categories.
Each category could have could have been assigned a different template.
Which template should be loaded?
The answer = the default template.
So if you have styled your tag.php in your template and you cant get it to display when a tag link in an item is clicked, you now know why.
Your tag over ride can still be used and displayed, but to see it requires a K2 tag menu link to be created.
Go ahead, create a menu link, select K2, then select the tag type.
In the basic parameters you can then select your K2 template over ride. Complete the rest of the required menu link settings, don't forget to select a tag and to publish it.
Now on the frontend, refresh and click on your newly created tag menu item, hey presto, your over ride style is loaded.
So how are we going to get the tag.php file from your template to display when a tag is clicked in an item?
Well, for now you will have to move your tag.php and replace the one in the default template.
Its also worth considering, that you will have to add any new css changes to k2.css in the component too.
Even if you use CSS4K2, it wont work on this view. I even tested this by creating a "default" template over ride in the Joomla template, but the component k2.css will still be loaded.
I think the following would be great if it could be implimented.
In the backend, we can edit tags, so why not allow the ability to select a K2 template which is loaded on a per tag basis, or assign a global template.
Assigning a global template would be essentially the same as saying hey, dont use the default, use this one on every view, but still allow the default to kick in if the view has not been included in the over ride.
Template over rides in K2 allow for some fantastically flexible layouts to be created, but you have to have some understanding on how best to use them, even after all these years, I am having to learn new tricks.
I hope this guide provides a little insight for you, creates some questions or gets you interested in diving into templating.