{"id":513,"date":"2010-10-05T16:46:17","date_gmt":"2010-10-05T14:46:17","guid":{"rendered":"http:\/\/www.kavdesign.net\/blog\/?p=513"},"modified":"2012-06-29T15:07:15","modified_gmt":"2012-06-29T13:07:15","slug":"modifying-the-tags-results-page-for-joomla-k2-creating-a-k2-template-over-ride","status":"publish","type":"post","link":"https:\/\/www.kavdesign.net\/blog\/coding\/modifying-the-tags-results-page-for-joomla-k2-creating-a-k2-template-over-ride\/","title":{"rendered":"Modifying the Tags Results Page for Joomla K2 + Creating a K2 Template Over Ride"},"content":{"rendered":"<p><span style=\"font-size: x-small;\">This is a handy little guide, if you want to change the way that your Tag Results page is displayed.<br \/>\nAs 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.<\/span><\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>Firstly, we are going to have to modify the generic.php file, this is located on components\/com_k2\/templates\/<br \/>\nNow, If you do not want to modify this core file, then you can create a new K2 template first.<br \/>\n<!--more--><br \/>\n<span style=\"font-size: medium;\">K2 Template Creation<\/span><span style=\"font-size: x-small;\"><br \/>\n<\/span><\/p>\n<ol>\n<li><span style=\"font-size: x-small;\">In your Joomla template, we need to create a new folder.<br \/>\nOn your server, navigate to templates\/YOURTEMPLATE\/html<\/span><\/li>\n<li><span style=\"font-size: x-small;\">Create a new folder called com_k2<\/span><\/li>\n<li><span style=\"font-size: x-small;\">Go to components\/com_k2 and copy the folder called templates<\/span><\/li>\n<li><span style=\"font-size: x-small;\">Paste this folder into templates\/YOURTEMPLATE\/html\/com_k2<\/span><\/li>\n<li><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">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.<\/span><\/span><\/li>\n<li><span style=\"font-size: x-small;\">Go to components\/com_k2\/css and copy the k2.css file.<\/span><\/li>\n<li><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">Paste the file to templates\/YOURTEMPLATE\/cssCss file is now copied, now for the image folders.<\/span><\/span><\/li>\n<li><span style=\"font-size: x-small;\">Goto components\/com_k2 and copy the images folder.<\/span><\/li>\n<li><span style=\"font-size: x-small;\">Paste the file to templates\/YOURTEMPLATE\/html\/com_k2<\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">You should now have all the required files in your Joomla template that will over ride the default K2 template.<br \/>\nAll you need do now, to use this template, is to set it within the Category Parameters in the K2 Control Panel.<br \/>\nAt 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.<\/span><br \/>\n<span style=\"font-size: medium;\"><br \/>\nModifying Your Tag Results<\/span><\/span><br \/>\n<span style=\"font-size: x-small;\"><br \/>\nNow we have our k2 template over ride in plate, we can modify our files without affecting the core files.<br \/>\nThis enables use to be completly flexible in the layout of pages so that they can differ from category to category.<\/span><\/p>\n<p>Lets now modify the Tags Result page.<\/p>\n<p>Setup Word Limit<\/p>\n<ol>\n<li><span style=\"font-size: x-small;\">To do this, we need to open the generic.php located in<\/span> <span style=\"font-size: x-small;\">templates\/YOURTEMPLATE\/html\/com_k2\/templates\/YOURK2TEMPLATE<\/span><\/li>\n<li><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">We need to modify the code, which can be seen in the following image.<\/span><\/span><img decoding=\"async\" src=\"http:\/\/api.ning.com\/files\/9tImKCxxjbIgy6O4Zug5sJaZtjLYsqq-IXNqiAGsmPI8WheCtpQET1I*Jwn0FHs7PEXw2rnALwc*TpyssgSGqmtFekBZ9XYF\/genericItemIntrotext.JPG\" alt=\"\" \/><br \/>\n<span style=\"font-size: x-small;\"><br \/>\n<\/span><\/li>\n<li><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">You will see that I have commented out (yellow) the original code on line 80 and added in some new code on line 81.<br \/>\nNotice, 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.<\/span><\/span>Now, instead of displaying a full item, you will just have the set number of words displayed.<\/li>\n<\/ol>\n<p>Remove Item Images<\/p>\n<p>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.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/api.ning.com\/files\/L*zLKYqKfbheYacq7AqaMZ*cWlOUhYBl5nL1l2yngaTQZrzdNuaLhH182gZ6W6fyZXu-mMrIKJhHt7DbOA4n3ZLG5ent7HdU\/genericItemImage.JPG?width=721\" alt=\"\" \/><\/p>\n<p>Add Page Title<\/p>\n<p>This next tip will display a page title which shows which tag name the accompanying list of items are related to.<br \/>\nThe image below shows the code we will be looking at.<\/p>\n<p><strong><a href=\"https:\/\/www.kavdesign.net\/blog\/coding\/modifying-the-tags-results-page-for-joomla-k2-creating-a-k2-template-over-ride\/attachment\/images\/\" rel=\"attachment wp-att-798\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-798\" title=\"images\" src=\"https:\/\/www.kavdesign.net\/blog\/wp-content\/uploads\/2010\/10\/images-494x45.jpg\" alt=\"\" width=\"494\" height=\"45\" srcset=\"https:\/\/www.kavdesign.net\/blog\/wp-content\/uploads\/2010\/10\/images-494x45.jpg 494w, https:\/\/www.kavdesign.net\/blog\/wp-content\/uploads\/2010\/10\/images-188x17.jpg 188w, https:\/\/www.kavdesign.net\/blog\/wp-content\/uploads\/2010\/10\/images.jpg 548w\" sizes=\"auto, (max-width: 494px) 100vw, 494px\" \/><\/a><\/strong><\/p>\n<p>Add in the code on Line2 41.<br \/>\nI have wrapped this in a H2, but you could add any class you wish to style it.<\/p>\n<p>So what does this all look like?<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/api.ning.com\/files\/XUMbj09KD5zNh3TWCKTQedYUj-NnKctoRRc-lgUnJ9iRUFLiyCDkGZwhKjSZTQoy70-UwhJCWIQC1SxrEx8hx9FQ4f6jtx64\/genericItemViewResults.JPG\" alt=\"\" \/><\/p>\n<p><span style=\"font-size: x-small;\">The image above shows our new Page Title &#8220;Displaying items by tag:&#8221; and &#8220;tag1&#8221; was the tag selected, of course some padding\/margins could have been used \ud83d\ude09<\/span><\/p>\n<p><span style=\"font-size: x-small;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-size: x-small;\">Our ItemImage is removed and our text limited.<\/span><\/p>\n<p><span style=\"font-size: x-small;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-size: x-small;\">One further thing that could be done, is to move the &#8220;Read More&#8221; from next to the &#8220;Published In&#8221; and place it at the end of the intro text.<\/span><\/p>\n<p><span style=\"font-size: x-small;\">Perhaps a little something for you to play with.<\/span><\/p>\n<p><span style=\"font-size: x-small;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-size: x-small;\">Hopefully you found this quick guide useful, comments are welcome.<\/span><\/p>\n<p><span style=\"font-size: x-small;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-size: x-small;\">Simon<br \/>\nK2 Support<\/span><br \/>\nOriginal artlicle: http:\/\/community.getk2.org\/profiles\/blogs\/modifying-the-tags-results<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.kavdesign.net\/blog\/coding\/modifying-the-tags-results-page-for-joomla-k2-creating-a-k2-template-over-ride\/\">Continue reading<span class=\"screen-reader-text\">Modifying the Tags Results Page for Joomla K2 + Creating a K2 Template Over Ride<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9,29],"tags":[417,98,103,35],"class_list":["post-513","post","type-post","status-publish","format-standard","hentry","category-coding","category-joomla","tag-joomla","tag-k2","tag-tags","tag-template","entry"],"_links":{"self":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/comments?post=513"}],"version-history":[{"count":6,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/513\/revisions"}],"predecessor-version":[{"id":797,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/513\/revisions\/797"}],"wp:attachment":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/media?parent=513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/categories?post=513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/tags?post=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}