K2 Templating: Tips to having greater control of your content

In this tutorial, we talk about how you can have different “item.php” files present different layouts for each subcategory.

This is another take on what I did in the previous tutorial, but instead of controlling the category listings page, it controls the actual item. If you pick a separate template for your subcategory, the “item.php” file is different for subcategory items.

We’ll be using this below structure as an example: 

  • – Blog
  • – – Seattle
  • – – Web
  • – – Design

 

Let’s assume that for your “Web” subcategory items you wanted the “item.php” to display a different layout than the rest of the “Blog” categories. You can assign a “web” template to the “Web” subcategory and edit its “item.php” file to fit your needs for that template. This way, when the user clicks on that item, the “web” template’s “item.php” will be pulled instead of the “blog” template’s “item.php”

So, to visually layout what we’re talking about, here is how things might be configured:

  • – Blog (blog template)
  • — Seattle (blog template)
  • — Web (web template)
  • — Design (blog template)

 

Make sure that when you do this, the subcategories have not inherited properites from the parent category.  You’ll have to setup the category settings separately.