K2 Templating: Understanding K2

The K2 Default template doesn’t always use all of the available options/values from the $item, $this->item, or the $category objects.  Sometimes you can dig just a bit deeper to find the answers you’re looking for…..

The best way to find what is available to you is by using the PHP print_r() function.

This will print off the entire item/categories’ array/object.  This is a really handy way to get access to data you didn’t know existed!

For example, you can figure out from the output that there is a value called $item->categoryalias which gives you the item’s parent’s alias.  This “categoryalias” value is definitely not used in the “Default” template.  You can figure out a lot of other information that you might want to use in your template by just exploring the data that is being given to you.

Just make sure to do it like this:

<!--
<?php print_r($item);?>
-->

I generally do not suggest doing this on a live system FYI; the code above is just a way to keep it clean.