27 May 2013

Joomla 2.5 Page Class Suffix

I was searching around the other day trying to find a way to add the page class suffix in Joomla 2.5 to the body as a class. This is very simple (and well documented) in Joomla 1.5 but Joomla 2.5 was proving to be a bit harder. In the end I came across the solution and posted it in the Joomla forums.

The code is very easy to implement just follow these instructions.

First of all add the following code to the top of the index.php file in your Joomla 2.5 template, below:

<?php defined('_JEXEC') or die;
Put:

<?php
$app = JFactory::getApplication('site');
$pageclass = & $app->getParams('com_content');
?>
Now replace the opening <body> tag with this:

<body class="<?php echo $pageclass ->get('pageclass_sfx'); ?>">

No comments:

Post a Comment