Customising Tag Views - Information
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.
Template Assignment
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.
The Problem
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.
An Alternative
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.
A solution
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.
A Suggestion
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.
Conclusion
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.
Creating Tabbed Content in K2 Items
Sometime you may need to display data within your content using a tabbed layout form.
This can easily be done using a great, free download from No Number called Tabber.
Once you have downloaded, then install just like any other Joomla! extension. This plugin is enabled during installation.
Please make sure you bookmark their documents pages too, so that you have access to the syntax required, but it so easy using the following code.
Take a look at the plugin in the Plugins Manager as it does have some parameters you can play with.
{ tab=Tab Title 1 } Your text... { tab=Tab Title 2 } Your text... { /tabs }
Using that code as an example, simply paste that into your K2 item. Please note, when you paste it, it may transfer some formatting from the site, so in your WYSIWYG editor, view the source and paste it their so that it strips any styling. Please also remove the blank space after "{" and before "}".
Let put that in to action.
OK, so now you have some tabs in your item, lets push it a stage further and display K2 item content in those tabs.
Again, we are going to use a plugin from No Number, this time, Articles Anywhere. Installation is as simple as before and again, there are some parameters that can be adjusted, but I have left the default settings in place.
This time, we drop in the Articles Anywhere syntax for K2 Items in place of the text we used before, which is as simple as { article k2:nnn } Please remove the blank space after "{" and before "}" and change nnn to the K2 Item ID number for the item you wish to display.
K2 Item 1
New Release - K2 Template ManagerI am pleased to announce that a new component has today been released in a joint collaboration be...
Custom read more!
K2 Item 2
|
Once installed, K2 Template Manager can be accessed from within the K2 extension. No need to go hunting for it amongst the other extensions, as it is located on the far right of the K2 features menu, after the information link. Go ahead, click on Templates. |
| Welcome to the template manager dashboard.
The primary display is a list of all the K2 templates which are installed in the component or Joomla templates. One of the cool things, is the use of the Custom CSS. This adds a copy of the default k2.css and places it with the K2 template that has been selected. |
|
If you click on one of the installed templates, the next screen will display a list of all the K2 categories and the templates which are currently assigned to it. This is a very quick way of selecting which categories are assigned a template, no more editing multiple categories. |
|
Template manager also lists out the files which are contained within the selected template, which if clicked can be edited. |
|
The code editor screen allows you to access the template css and php files, so that they can be edited from the Joomla backend, without the need for 3rd party software or having to set up ftp access to your server files. |
| So now your all set to manage your K2 templates through Joomla, no more guess work on where to place your template. |
.
K2 Item 2
Installation is just like any other Joomla extension installation. Subscribers will need to have downloaded a copy.
- Login to your Joomla Administration
- From the main Menu, navigate to Extensions> Install/Uninstall
- In the Extension Manager window, click on the Choose File button.
This will open a pop up window, allowing to find the relevant file on your local drive.
Additionally, you may store your downloads on your server or paste a link directly to the download file.
The later will only work if you have an active subscription. - Click either Upload & Install of just Install, depending on which installation option you chose in step 3.
- Once installed, you will see the installation confirmation text.
Thats it, installation is now complete, time to check out the features.
Now the smart thing is, tab 1 has some additional syntax so that it shows the title, 100 characters of text and then a custom read more.
Full details can be found in the plugin parameters on in the No Number documents.
{ tab=K2 Item 1 } { article k2:nnn } { title } { text:50 } { readmore:Custom read more! } { /article }
Thats it all done.
Play and enjoy.








