Folks, I'm attempting to implement a rudimentary feature in Joomla but getting no luck getting my mind around it.

My client has setup Joomla with several sections each section getting its very own groups and finally content underneath.

I want each section to possess a slightly different color component (e.g. Section A and it is all subsequent child pages red-colored, Section B - blue, etc) certain edges and skills have to be unique based on each section.

I've one theme which is often used by all sections. Somewhere within the theme file, I have to identify which section I'm on, and according to that set a css variable accordingly:

    <body class="cars-section">


All I want would be to set my body's class right section, and all sorts of my coloring continues to be setup to operate like magic.

Any ideas how this is often completed in the Joomla world? Can there be one other way to do this type of factor.

You have to select the section ID up in the request.

Make use of this to obtain the relevant request variables:

$option = JRequest::getWord('option', null);
$view = JRequest::getWord('view', null);
$idalias = JRequest::getVar('id', null);
if (strpos($idalias, ":") != false) {
    $idandalias = explode(":", $idalias);
    $id = $idandalias[0];
} else {
    $id = JRequest::getInt ('id' , 0);

Then use something similar to this to determine what section you're in, if you're on the section page:

if ( $option=="com_content" && $view=="section" ) {
  $sectid = $id;

In section pages you can easily make use of the request, however in other pages you have to perform a database query too:

else {
  $database =& JFactory::getDBO();
  if ( $option=="com_content" && $view=="category" ) {
    $query = "SELECT section FROM jos_categories WHERE id=$id";
  if ( $option=="com_content" && $view=="article" } {
    $query = "SELECT sectionid FROM jos_content WHERE id=$id";
  $sectid = $database->loadResult();

If you have the section ID technology-not only to create and place the best class.

if ( $sectid == '3' ) {
  $my_cars_section_class = 'three';
<body class="<?php echo $my_cars_section_class; ?>">

Something of that nature must do it.

You will find a few methods to achieve body css-classing:

  1. Utilize Joomla's menu page class suffix system.
  2. Output the course in line with the selected menu link from inside web site. Obviously, if you are planning to get this done, you will need to modify your template a little.

    $menu = &JSite::getMenu()
    $active = $menu->getActive()
    <body <?php if($active->alias) echo 'class="' .$active->alias .'"' ?>>