adding page class suffix problems

GK User
Tue Jan 25, 2011 1:53 am
I've added a page class suffix to one of my menu items within Party Freak (the suffix is "banner-ads" and is added with a leading white space) but it doesn't seem to be adding itself to the "page" only to the "h2" tag.


Any ideas?


1-25-2011 8-51-52 AM.png
User avatar
Expert Boarder

GK User
Thu Jan 27, 2011 6:54 pm
No help anyone? :(
User avatar
Expert Boarder

teitbite
Sat Jan 29, 2011 8:20 pm
Hi

Yeah I was also not happy when I realized that "page class suffix" is for content only. You can hack the template code to make it a real bomb :)

Code: Select all
   <?php
      $pageclass_sfx = '';
      if( !isset( $_GET['Itemd'] ) ) {
         $query = 'SELECT m.params AS params FROM jos_menu AS m WHERE m.id = ' . $_GET['Itemid'];
         $row = mysql_fetch_assoc( mysql_query( $query ) );
         $pageParams = explode( "n", $row['params'] );
         foreach( $pageParams as $value ) {
            if( substr( $value, 0, 14 ) == 'pageclass_sfx=' )
               $pageclass_sfx = 'class="' . trim( substr( $value, 14, strlen( $value ) ) ) . '"';
         } // eof foreach()
      } // eof if()
   ?>

<body <?php echo $pageclass_sfx; ?>>

User avatar
Moderator

GK User
Sun Jan 30, 2011 12:45 am
Hi Teitbite,

What does the code do that you posted . . . ?

Chris
User avatar
Expert Boarder

teitbite
Sun Jan 30, 2011 3:13 am
Hi

Magic :) This is adding page class prefix to body so You can customize every page differetly.
User avatar
Moderator

GK User
Fri May 27, 2011 4:42 pm
While Gavick templates are generally some of the easiest to work with, i don't like it when templates change what is ( or should be ) a standard feature of joomla!, eg: the page class suffix feature. The standard Joomla! way to do it is like this:

Page Class Suffix by Itemid, put this in your index.php file, usually in the layouts/default.php file of your template folder:

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' );
?>


And then down towards the bottom of that page you add:
Code: Select all
<body id="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">


So it would look something like this:

Code: Select all
<body id="bd" class="fs<?php echo $this->getParam(GK_TOOL_FONT);?> <?php echo $this->browser();?> <?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">
User avatar
Fresh Boarder


cron