This tutorial will walk you through the process of creating a custom layout for a particular type.
Note Items that are not categorized will not show in the alpha index.
Before you read this tutorial, make sure you've read the tutorial about creating new layouts with positions.
Creating a custom layout for a particular type is similar to the above mentioned process. Except the layouts will go into
So lets create a layout
demo for a type
demo_type. The first step is to create the folder
/media/zoo/applications/APPLICATION/templates/TEMPLATE/renderer/item/demo_type/. We will add all layouts for the type
demo_type into this folder. You will need to create the files
metadata.xml as described in the above tutorial. Again, the
positions.config is not to be touched.
To create the demo layout, just follow the steps in the above tutorial. Basically the only difference is that the layout will not go into the
/item/ folder, but into the
/item/TYPE/ folder and you'll have to create the two xml files.
$this->renderer->render('item.demo_type.demo', array('view' => $this, 'item' => $this->item));
To render the item with the new layout, the call to the render function will have to be modified too. Similar to the code above.
if ($this->item->type == 'demo_type') : echo $this->renderer->render('item.demo_type.demo', array('view' => $this, 'item' => $this->item)); else: echo $this->renderer->render('item.full', array('view' => $this, 'item' => $this->item)); endif;
You can wrap the render function in an if clause to check for an item type, with the code above. Please make sure to check against the types alias (name of the types config file).
That's it. Now you can add custom layouts for particular types. That's a neat feature to prevent the layout list in the Joomla administration from bloating itself. It also enables you to limit the selectable layouts for the relateditems element display options.