Skip to content

Modifying the Tags Results Page for Joomla K2 + Creating a K2 Template Over Ride

This is a handy little guide, if you want to change the way that your Tag Results page is displayed.
As default, when you click on a Tag Link in a K2 Item, it will produce a page showing all full items which have that particular tag.

Now, if you Items contain a lot of information or you have a lot of Items with the same Tag, you will end up with quite a long list.

This little guide will explain how to reduce the displayed data to show just a snippet of the Item information plus add a bit of extra information.

Firstly, we are going to have to modify the generic.php file, this is located on components/com_k2/templates/
Now, If you do not want to modify this core file, then you can create a new K2 template first.

K2 Template Creation

  1. In your Joomla template, we need to create a new folder.
    On your server, navigate to templates/YOURTEMPLATE/html
  2. Create a new folder called com_k2
  3. Go to components/com_k2 and copy the folder called templates
  4. Paste this folder into templates/YOURTEMPLATE/html/com_k2
  5. Go to templates/YOURTEMPLATE/html/com_k2/templates and rename the folder called default to something more meaningful for you. If you keep it as default, it will only cause you confusion later on.That is all the K2 template files copied, now for the css.
  6. Go to components/com_k2/css and copy the k2.css file.
  7. Paste the file to templates/YOURTEMPLATE/cssCss file is now copied, now for the image folders.
  8. Goto components/com_k2 and copy the images folder.
  9. Paste the file to templates/YOURTEMPLATE/html/com_k2

You should now have all the required files in your Joomla template that will over ride the default K2 template.
All you need do now, to use this template, is to set it within the Category Parameters in the K2 Control Panel.
At this stage, the K2 default template will always be used for all new Categories that are created, but you can of course select your new K2 template.

Modifying Your Tag Results

Now we have our k2 template over ride in plate, we can modify our files without affecting the core files.
This enables use to be completly flexible in the layout of pages so that they can differ from category to category.

Lets now modify the Tags Result page.

Setup Word Limit

  1. To do this, we need to open the generic.php located in templates/YOURTEMPLATE/html/com_k2/templates/YOURK2TEMPLATE
  2. We need to modify the code, which can be seen in the following image.

  3. You will see that I have commented out (yellow) the original code on line 80 and added in some new code on line 81.
    Notice, the red circle around the number 30. This sets the introtext to display 30 words, you can of course change this to how you want.
    Now, instead of displaying a full item, you will just have the set number of words displayed.

Remove Item Images

If you do not want your Item Images to be displayed, to keep this view clean and simple, then you will need to remove or comment out some more code. The image below shows which code is used.

Add Page Title

This next tip will display a page title which shows which tag name the accompanying list of items are related to.
The image below shows the code we will be looking at.

Add in the code on Line2 41.
I have wrapped this in a H2, but you could add any class you wish to style it.

So what does this all look like?

The image above shows our new Page Title “Displaying items by tag:” and “tag1” was the tag selected, of course some padding/margins could have been used 😉

Our ItemImage is removed and our text limited.

One further thing that could be done, is to move the “Read More” from next to the “Published In” and place it at the end of the intro text.

Perhaps a little something for you to play with.

Hopefully you found this quick guide useful, comments are welcome.

K2 Support

Original artlicle:

Published inCodingJoomla


  1. Brenda

    This was extremely helpful!! Can you tell what the code would be to limit the word count of the title:
    params->def( ‘show_page_title’, 1 ) ) : ?>
    <div class="componentheadingescape($this->params->get(‘pageclass_sfx’)); ?>”>
    escape($this->params->get(‘page_title’)); ?>

  2. stephen

    this is fantastic… thanks….

    can you advise if it is possible to restructure the page as well as limiting into info presented…

    i.e. i have 3000+ videos in around 20 tags… so ideally when a tag is clicked, i want to present a single image and title for each vid within that tag…

    rather than 1 column and millions of rows… common sense would be to display in say 4-5columns, single pics that link to each article….

    [ ] [ ] [ ] [ ]
    [ ] [ ] [ ] [ ]
    [ ] [ ] [ ] [ ]

    rather than

    [ ]
    [ ]
    [ ]
    [ ]
    (this is the default in k2)

    many thanks

  3. Stephan Herby

    Just to tell you that this Tip still works in K2 2.5.4 under Joomla 2.5.1 except the fact that the file is tag.php and not generic.php anymore.
    Thank you so much for this big big help…

  4. Simon Wells

    Hi Stephan,

    Yes you are right. Since Version 2.5 of K2, the tags view was taken out of the generic view and given its separate tag.php.

    I am glad that so many K2 users have found this useful.


  5. Simon Wells

    The removal of the tag image code is no longer necessary in 2.5 and above as K2 gloabl parameters now includes switches to turn on/off popular elements such as intro text, images, tags.

    There is still no page title though, so if you have not linking through a menu item pointing to the tag, then you could be left wondering what page you are on.


  6. Simon Wells

    Finally, since K2 ning site was taken down, I will be re-releasing this content on K2joom, as it was originally only submitted on the K2 community portion.
    As that no longer exists, I shall be bringing that out soon.


  7. Stefano Virgilli

    Hi, it would be super useful, but it seems like all the pictures are gone…

  8. maxg

    Images links are broken, is it possible to fix those?

  9. simon wells

    Sorry for the missing images, but this article was taken from the previous k2 site or from k2joom site without permission.

  10. Chris

    I could use this solution too. Where is the new location of your article? I would very much appreciate if you could email me the excerpt. Thank you.

  11. Vangelis

    Is there a way to add modules on the right, bottom etc to the tag results page?

  12. ibanez0r

    im using j3+k2 and the tags link only to a 404 page? why is that?

Comments are closed.