Page Class Suffix in template code

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Mihc
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Mon Aug 28, 2006 3:23 pm

Re: Page Class Suffix in template code

Post by Mihc » Fri Apr 13, 2012 7:06 am

I don't know where is the error, but if i try this code i get blank page. If i don't echo $pageclass the page loads without problems.
I used this article:
http://docs.joomla.org/Using_the_Page_C ... plate_Code
and if i use

Code: Select all

<body id="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">
i always get id default. I guess J! can't get page class suffix. I don't know why not...
Any ideas?

User avatar
tinocordes
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Tue Apr 15, 2008 7:54 am
Location: Denmark
Contact:

Re: Page Class Suffix in template code

Post by tinocordes » Thu Jun 07, 2012 10:59 am

adelion wrote:Here is a solution for 2.5.x users:

Code: Select all

<?php
  $itemid = JRequest::getVar('Itemid');
  $menu = &JSite::getMenu();
  $active = $menu->getItem($itemid);
  $params = $menu->getParams( $active->id );
  $pageclass = $params->get( 'pageclass_sfx' );
?>

<html>
<head>
<jdoc:include type="head" />
</head>

<body class="<?php echo $pageclass ?>">
Thanks! This works for me :-) At first I forgot that I hadn't assigned a class to the specific menu link in the admin.

User avatar
Helvecio
Joomla! Explorer
Joomla! Explorer
Posts: 468
Joined: Wed Oct 10, 2007 2:29 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Page Class Suffix in template code

Post by Helvecio » Sun Jan 13, 2013 3:37 pm

FYI, I implemented the original code from the beginning of this thread in 2.5.8 and it's working like a charm!

Code: Select all

<?php
   $menus      = &JSite::getMenu();
   $menu      = $menus->getActive();
   $pageclass   = "";
    
   if (is_object( $menu )) :
   $params = new JParameter( $menu->params );
   $pageclass = $params->get( 'pageclass_sfx' );
    endif; ?>
Then in the BODY tag:

Code: Select all

<body class="<?php echo $pageclass; ?>">
tinocordes wrote:
adelion wrote:Here is a solution for 2.5.x users:

Code: Select all

<?php
  $itemid = JRequest::getVar('Itemid');
  $menu = &JSite::getMenu();
  $active = $menu->getItem($itemid);
  $params = $menu->getParams( $active->id );
  $pageclass = $params->get( 'pageclass_sfx' );
?>

<html>
<head>
<jdoc:include type="head" />
</head>

<body class="<?php echo $pageclass ?>">
Thanks! This works for me :-) At first I forgot that I hadn't assigned a class to the specific menu link in the admin.
Helvecio "Elvis" da Silva
Graphic and Web Designer
Joomla Website Developer
http://hlvc.design

User avatar
creativesights
Joomla! Guru
Joomla! Guru
Posts: 642
Joined: Tue Jan 13, 2009 11:50 pm
Location: San Diego, California, USA
Contact:

Re: Page Class Suffix in template code

Post by creativesights » Tue Jan 22, 2013 4:09 am

Anyone have any experiences with sh404SEF blocking this or page class suffixes in general? Having issues and think this may be my issue.
Andrew Crossan
CreativeSights
Professional Custom Website Design & Development in San Diego
https://www.creativesights.com


Locked

Return to “Templates for Joomla! 1.5”