Link to home
Start Free TrialLog in
Avatar of smfmetro10
smfmetro10Flag for United States of America

asked on

Joomla Body ID Tag Using Menu Item Alias

Hi,

I am trying to create unique body tags for each of my pages in my custom template that I created for Joomla.  In my custom template index.php file, I used the code:
 
<?php
$menu = &JSite::getMenu();
$active = $menu->getActive();
?>
<body id="page_<?php print $active->alias; ?>">

Open in new window


in place of the <body> tag.  

In my Joomla admin panel, I go to Menus -> Menu Manager, and click "Menu Items" in the Main Menu row.  I have two items in there: Home (was in there already)  and Courses.  When I click on "Courses," it goes to the editing screen, and the Alias says "courses."  (and it refers to an article "Courses" in the parameters area.

So theoretically, my body tag should say <body id="page_courses">, but it doesn't.  However, the home page DOES work and says: <body id="page_home">, so I know I'm doing something right.  I just must have a setting wrong for the "courses" menu item/article.

Any suggestions?  Is that enough info to go on?

I'm a Joomla newbie, btw.

Thanks!
Avatar of Avinash Zala
Avinash Zala
Flag of India image

try this:

      <?php
$menu = &JSite::getMenu();
$active = $menu->getActive();
?>
<body id="page_<?php echo $active->alias; ?>">


I think you are doing ok.

Thanks
Addy
ASKER CERTIFIED SOLUTION
Avatar of smfmetro10
smfmetro10
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial