Page Class Suffix in template code
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
-
- Joomla! Apprentice
- Posts: 14
- Joined: Mon Oct 20, 2008 3:58 pm
Re: Page Class Suffix in template code
its http://www.sonic-rites.com
i want a different style to show on the artist content items
Thanks for taking the time to look
i want a different style to show on the artist content items
Thanks for taking the time to look
Ralphonz
http://www.sonic-rites.com/
http://www.sonic-rites.com/
- mark_up
- Joomla! Guru
- Posts: 849
- Joined: Sun Oct 29, 2006 10:51 am
- Location: Fiji
- Contact:
Re: Page Class Suffix in template code
Hmmm... Replicant is a little complicated.
Parts of the style are controlled by , so maybe use that for your different pages (with Ninja Style).
If you just want to change the background image per page, there is some code on the RT forums contributed by a member for that (if i recall correctly). Look in the member submissions forum.
I don't know all that much about Replicant, having never used it, but I suspect MuffinDCC, who posted earlier in this thread, might just know a little about that templates inner workings.
Sorry if that isn't much help. You picked a tough (but very sexy) template to work with
Parts of the style are controlled by
Code: Select all
http://www.sonic-rites.com/templates/rt_replicant/css/header-XXXX.css
If you just want to change the background image per page, there is some code on the RT forums contributed by a member for that (if i recall correctly). Look in the member submissions forum.
I don't know all that much about Replicant, having never used it, but I suspect MuffinDCC, who posted earlier in this thread, might just know a little about that templates inner workings.
Sorry if that isn't much help. You picked a tough (but very sexy) template to work with
http://twitter.com/mark_up.
Opinions expressed are mine alone and don't necessarily represent the views of any organisation I am associated with.
Opinions expressed are mine alone and don't necessarily represent the views of any organisation I am associated with.
-
- Joomla! Fledgling
- Posts: 1
- Joined: Wed Nov 26, 2008 7:02 pm
Page Class Suffix to call in a style sheet
My goal is, rather than modifying individual CSS classes based on the Page Class Suffix, to call in a whole stylesheet using that suffix.
looking at the code posted above:
i'm wondering if anyone thinks there should be any problem with linking in a stylesheet based on $pageclass, rather than using $pageclass to modify the class of <body>?
e.g. replacing the last two lines of the above with:
with the various files ($pageclass).css containing the styles for pages with that page class suffix.
Is there any reason this shouldn't work in index.php for my site?
looking at the code posted above:
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;
?>
</head>
<body class="<?php echo $pageclass; ?>">
e.g. replacing the last two lines of the above with:
Code: Select all
<link rel="stylesheet" href="http://mywebsite.com/templates/mytemplate/css/<?php echo $pageclass ?>.css" type="text/css" />
Is there any reason this shouldn't work in index.php for my site?
- MuffinDCC
- Joomla! Explorer
- Posts: 347
- Joined: Wed Nov 22, 2006 9:07 am
- Location: UK
- Contact:
Re: Page Class Suffix in template code
That seems a perfectly reasonable approach, just remove the class from the <body>.
-
- Joomla! Fledgling
- Posts: 1
- Joined: Tue Dec 16, 2008 4:37 pm
Re: Page Class Suffix in template code
Hi, this code is great, exactly what I'm looking for!
It works perfectly in all browsers but IE6, I just couldn't get it to load my backgrounds there, and I want to have a different background on every page.
The last idea, with loading a new CSS file works in IE6 as well, but I'd rather use the body class than load so many CSS files. Any ideas?
It works perfectly in all browsers but IE6, I just couldn't get it to load my backgrounds there, and I want to have a different background on every page.
The last idea, with loading a new CSS file works in IE6 as well, but I'd rather use the body class than load so many CSS files. Any ideas?
-
- Joomla! Intern
- Posts: 57
- Joined: Wed Sep 10, 2008 6:08 am
- Location: Sweden
- Contact:
Re: Page Class Suffix in template code
Hi,
Thanks a lot for this, it's exactly what I'm looking for. Saved me lots of searching time!
Regards,
Floddy
Thanks a lot for this, it's exactly what I'm looking for. Saved me lots of searching time!
Regards,
Floddy
- bobbravo2
- Joomla! Apprentice
- Posts: 39
- Joined: Sun Jul 22, 2007 10:45 pm
- Location: Orlando, FL
- Contact:
Re: Page Class Suffix in template code
MuffinDCC wrote:This code works for me and doesn't display any errors.
*This is my 3rd edit of this post with all the code lol *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; ?> </head> <body class="<?php echo $pageclass; ?>">
Thanks this works beautifully!
- TomT
- Joomla! Ace
- Posts: 1324
- Joined: Thu Aug 18, 2005 5:50 am
- Location: Amsterdam
- Contact:
- kavaXtreme
- Joomla! Intern
- Posts: 74
- Joined: Tue Dec 13, 2005 9:56 pm
- Location: Oregon
- Contact:
Re: Page Class Suffix in template code
Much appreciated!
A tutorial based on this thread can now be found here:
http://docs.joomla.org/Using_the_Page_C ... plate_Code
A tutorial based on this thread can now be found here:
http://docs.joomla.org/Using_the_Page_C ... plate_Code
- Bible Yellow Pages: http://www.bibleyp.com
- ltempest
- Joomla! Guru
- Posts: 600
- Joined: Thu Aug 25, 2005 11:16 am
- Location: Gloucester, UK
- Contact:
Re: Page Class Suffix in template code
Does the page DOCTYPE matter when using this code?
I have followed the tutorial exactly and copied and pasted the code for item id, but nothing gets put in the body ID tag other than 'default' no matter what menu item I click on.
Any help most appreciated. I include my code below for reference:
I have followed the tutorial exactly and copied and pasted the code for item id, but nothing gets put in the body ID tag other than 'default' no matter what menu item I click on.
Any help most appreciated. I include my code below for reference:
Code: Select all
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >
<?php
$itemid = JRequest::getVar('Itemid');
$menu = &JSite::getMenu();
$active = $menu->getItem($itemid);
$params = $menu->getParams( $active->id );
$pageclass = $params->get( 'pageclass_sfx' );
?>
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="templates/<?php echo $this->template ?>/css/template_css.css" type="text/css" />
<link rel="stylesheet" href="templates/<?php echo $this->template ?>/css/test.css" type="text/css" />
<link rel="stylesheet" href="css/test.css" type="text/css" />
</head>
<body id="<?php echo $pageclass ? $pageclass : 'default'; ?>">
<div id="main">
<div id="header_area"></div>
<?php if($this->countModules('user1')) : ?><jdoc:include type="modules" name="user1" style="xhtml" /><?php endif; ?>
<div id="contentarea">
<?php if($this->countModules('user2')) : ?><jdoc:include type="modules" name="user2" style="xhtml" /><?php endif; ?>
<jdoc:include type="component" />
<?php if($this->countModules('user3')) : ?><jdoc:include type="modules" name="user3" style="xhtml" /><?php endif; ?>
<?php if($this->countModules('user4')) : ?><jdoc:include type="modules" name="user3" style="xhtml" /><?php endif; ?>
</div>
<div id="footer">
<?php if($this->countModules('user5')) : ?><jdoc:include type="modules" name="user5" style="xhtml" /><?php endif; ?>
<?php if($this->countModules('user6')) : ?><jdoc:include type="modules" name="user6" style="xhtml" /><?php endif; ?>
<?php if($this->countModules('user7')) : ?><jdoc:include type="modules" name="user7" style="xhtml" /><?php endif; ?>
</div>
</div>
</body>
</html>
- TomT
- Joomla! Ace
- Posts: 1324
- Joined: Thu Aug 18, 2005 5:50 am
- Location: Amsterdam
- Contact:
Re: Page Class Suffix in template code
I placed the code in the head of index.php. You placed it before the head tag, try changing this.
-
- Joomla! Apprentice
- Posts: 17
- Joined: Sun Nov 15, 2009 5:49 am
Re: Page Class Suffix in template code
great work ....
I was trying to change the div classes inside the body, but the codes listed above is not working. Is that this works with the body tag only? If it is so please anyone help me out changing the div classes suffix according to selected menu..
I was trying to change the div classes inside the body, but the codes listed above is not working. Is that this works with the body tag only? If it is so please anyone help me out changing the div classes suffix according to selected menu..
- TomT
- Joomla! Ace
- Posts: 1324
- Joined: Thu Aug 18, 2005 5:50 am
- Location: Amsterdam
- Contact:
Re: Page Class Suffix in template code
On http://leontinelieffering.nl/ i've got it working for a div inside the body. I Use it this way: <div id="content<?php echo $pageclass; ?>"><jdoc:include type="component" /></div>_prakash wrote:great work ....
I was trying to change the div classes inside the body, but the codes listed above is not working. Is that this works with the body tag only? If it is so please anyone help me out changing the div classes suffix according to selected menu..
-
- Joomla! Apprentice
- Posts: 9
- Joined: Mon Feb 02, 2009 7:36 pm
- Location: Red Deer, Alberta, Canada
- Contact:
Re: Page Class Suffix in template code
Hello,
I have tried adding this code
to the RT Mixxmag index.php template file just above </head>, but the results are not working as they should.
I have also added this code to the <body> tag. The other styles are part of the core coding developed by Rocket Theme. Here is the generated source for the <body> tag
Only a double space is rendered in this spot instead of the page class suffix.
I have added the page class suffix to the menu item, but the code is not being rendered correctly.
I hope someone can help me with this issue and I thank you in advance for your time.
Joomla 1.5.10
RT Mixxmag template version 1.5.2
I have tried adding this code
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; ?>
I have also added this code
Code: Select all
<body id="ff-<?php echo $fontfamily; ?>" class="<?php echo $fontstyle; ?> <?php echo $pageclass; ?> <?php echo $tstyle; ?> iehandle">
Code: Select all
<body id="ff-mixxmag" class="f-default "Page class should be echoed here" style1 iehandle">
I have added the page class suffix to the menu item, but the code is not being rendered correctly.
I hope someone can help me with this issue and I thank you in advance for your time.
Joomla 1.5.10
RT Mixxmag template version 1.5.2
-
- Joomla! Apprentice
- Posts: 6
- Joined: Fri Apr 10, 2009 8:36 am
- Location: France (South)
Re: Page Class Suffix in template code
Great, it works, thank you for this nice tipsMuffinDCC wrote:This code works for me and doesn't display any errors.
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; ?> </head> <body class="<?php echo $pageclass; ?>">
-
- Joomla! Apprentice
- Posts: 6
- Joined: Fri Apr 10, 2009 8:36 am
- Location: France (South)
Re: Page Class Suffix in template code
Hello,mik0209jmla wrote: Only a double space is rendered in this spot instead of the page class suffix.
I have added the page class suffix to the menu item, but the code is not being rendered correctly.
Double white space ? it seems that no menu object was found !
The double white space appears when clicking on the menu you have added a suffix ?
Have you put the php code before the body tag ?
-
- Joomla! Apprentice
- Posts: 9
- Joined: Mon Feb 02, 2009 7:36 pm
- Location: Red Deer, Alberta, Canada
- Contact:
Re: Page Class Suffix in template code
Hello,
I submitted a posting on the Rocket Theme forums and found out the problem was related to the parent menu item not being published. I tested it on a local server and everything is functioning as it should.
Thank you for your input.
I submitted a posting on the Rocket Theme forums and found out the problem was related to the parent menu item not being published. I tested it on a local server and everything is functioning as it should.
Thank you for your input.
-
- Joomla! Apprentice
- Posts: 31
- Joined: Sun Sep 11, 2005 11:19 pm
- Location: Brisbane, Australia
- Contact:
Re: Page Class Suffix in template code
does this code work in joomla 1.6? I have been trying with no success?
- gavjof
- Joomla! Intern
- Posts: 64
- Joined: Wed Nov 08, 2006 11:06 am
Re: Page Class Suffix in template code
Great topic. Thanks for all the work.kavaXtreme wrote:Much appreciated!
A tutorial based on this thread can now be found here:
http://docs.joomla.org/Using_the_Page_C ... plate_Code
A note: I believe there is a syntax error in the docs page.
By Active menu is:
Code: Select all
$pageclass = $params->get( 'pageclass_sfx' ));
Code: Select all
$pageclass = $params->get( 'pageclass_sfx' );
-
- Joomla! Apprentice
- Posts: 31
- Joined: Sun Sep 11, 2005 11:19 pm
- Location: Brisbane, Australia
- Contact:
Re: Page Class Suffix in template code
can anyone give me a working example of code for joomla 1.6
I am currently using this
-------------- in the head -------------
<?php defined('_JEXEC') or die('Restricted access');
$menus = &JSite::getMenu();
$menu = $menus->getActive();
$pageclass = "";
if (is_object( $menu )) :
$params = new JParameter( $menu->params );
$pageclass = $params->get( 'pageclass_sfx' );
endif;
echo '<?xml version="1.0" encoding="utf-8"?'.'>'; ?>
--------------in the body --------------
<?php if ($pageclass == "_home") { ?>
<?php } ?>
I am currently using this
-------------- in the head -------------
<?php defined('_JEXEC') or die('Restricted access');
$menus = &JSite::getMenu();
$menu = $menus->getActive();
$pageclass = "";
if (is_object( $menu )) :
$params = new JParameter( $menu->params );
$pageclass = $params->get( 'pageclass_sfx' );
endif;
echo '<?xml version="1.0" encoding="utf-8"?'.'>'; ?>
--------------in the body --------------
<?php if ($pageclass == "_home") { ?>
<?php } ?>
-
- Joomla! Enthusiast
- Posts: 151
- Joined: Fri Apr 16, 2010 3:03 pm
- Location: Scarborough, UK
- Contact:
Re: Page Class Suffix in template code
For Joomla 1.6 use this in the head:
And then this for the <body> tag:
Code: Select all
<?php
$app = JFactory::getApplication('site');
$pageclass = & $app->getParams('com_content');
?>
Code: Select all
<body class="<?php echo $pageclass ->get('pageclass_sfx'); ?>">
Director / Designer at Betton Design Ltd, Scarborough.
https://bettondesign.co.uk/
https://bettondesign.co.uk/
-
- Joomla! Apprentice
- Posts: 5
- Joined: Thu Aug 04, 2011 4:28 pm
Re: Page Class Suffix in template code
Hello everyone,
that very usefull code is not working for me !
I've tried both possibilities, placed them in different places in my index.php...
the $pageclass variable remains desparetely empty...
Anyone who's had the same problem and found a solution ?
Thanks for the help you could give.
Webslave
(Joomla 1.5.20)
that very usefull code is not working for me !
I've tried both possibilities, placed them in different places in my index.php...
the $pageclass variable remains desparetely empty...
Anyone who's had the same problem and found a solution ?
Thanks for the help you could give.
Webslave
(Joomla 1.5.20)
-
- Joomla! Enthusiast
- Posts: 151
- Joined: Fri Apr 16, 2010 3:03 pm
- Location: Scarborough, UK
- Contact:
Re: Page Class Suffix in template code
@webSlaveParis
My version won't work because it only applies to Joolma 1.6 and 1.7
I suggest you go back and read this thread properly for Joomla 1.5
My version won't work because it only applies to Joolma 1.6 and 1.7
I suggest you go back and read this thread properly for Joomla 1.5
Director / Designer at Betton Design Ltd, Scarborough.
https://bettondesign.co.uk/
https://bettondesign.co.uk/
-
- Joomla! Apprentice
- Posts: 5
- Joined: Thu Aug 04, 2011 4:28 pm
Re: Page Class Suffix in template code
I have read it properly and thouroughly...
-
- Joomla! Fledgling
- Posts: 1
- Joined: Tue Aug 09, 2011 5:31 pm
- Contact:
Re: Page Class Suffix in template code
Working perfectly for me. Thanks, really appreciate it
-
- Joomla! Apprentice
- Posts: 26
- Joined: Thu Mar 18, 2010 1:56 pm
Re: Page Class Suffix in template code
Hello
I added
and
on my index.php file.
I put on menu page suffix place the suffixes and everything works perfect.
BUT i have problems with 2 components that see this only on the page that menu is linked on.
On other pages of the same component i got this
Can someone help me to solve this problem because the css file cant be loaded.
Thank you
I added
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' );
?>
Code: Select all
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/css/<?php echo $pageclass ?>.css" type="text/css" />
I put on menu page suffix place the suffixes and everything works perfect.
BUT i have problems with 2 components that see this only on the page that menu is linked on.
On other pages of the same component i got this
Code: Select all
<link rel="stylesheet" href="/templates/rhuk_milkyway/css/.css" type="text/css" />
Thank you
-
- Joomla! Apprentice
- Posts: 15
- Joined: Tue Nov 23, 2010 2:37 pm
Re: Page Class Suffix in template code
This sounds so great and exactly what I need...:-) BUT....my "index.php" for my template looks like this:MuffinDCC wrote:I modified the code so it was a bit leaner, it was a bit ... long winded as I was testing it out. So, for anyone wanted to implement it, just follows these steps:-
1. Open your template's index.php file (located in /templates/*template-name*/)
2. Find the </head> tag in the index.php, should be near the top area of the template
index.php
PHP script text
?><?php
/**
* @package yoo_neo Template
* @file index.php
* @version 5.5.1 August 2010
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) 2007 - 2010 YOOtheme GmbH
* @license YOOtheme Proprietary Use License (http://www.yootheme.com/license)
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// include config
include_once(dirname(__FILE__).'/config.php');
// load main template file, located in /layouts/template.php
echo $warp->template->render('template');
So, I go to the "template.php" and get this....
template.php
PHP script text
<?php
/**
* @package yoo_neo Template
* @file template.php
* @version 5.5.1 August 2010
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) 2007 - 2010 YOOtheme GmbH
* @license YOOtheme Proprietary Use License (http://www.yootheme.com/license)
*/
// get template configuration
include(dirname(__FILE__).'/template.config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->warp->config->get('language'); ?>" lang="<?php echo $this->warp->config->get('language'); ?>" dir="<?php echo $this->warp->config->get('direction'); ?>" >
<head>
<?php echo $this->warp->template->render('head'); ?>
<link rel="apple-touch-icon" href="<?php echo $this->warp->path->url('template:apple_touch_icon.png'); ?>" />
</head>
<body id="page" class="yoopage <?php echo $this->warp->config->get('columns'); ?> <?php echo $this->warp->config->get('itemcolor'); ?> <?php echo $this->warp->config->get('toolscolor'); ?> <?php echo $this->warp->config->get('frontpage'); ?> <?php echo $this->warp->config->get('webfonts'); ?>">
<?php if ($this->warp->modules->count('absolute')) : ?>
<div id="absolute">
<?php echo $this->warp->modules->render('absolute'); ?>
</div>
<?php endif; ?>........cont.
Can you please tell me where to insert this code??...:-(
I need just 1 page with a dk red background...I have this, but please look at the "wrapper" edge...it is still white. I need the whole page red...:-(
http://174.132.147.99/~renonati/index.p ... &Itemid=10
Thanks!
karen
-
- Joomla! Apprentice
- Posts: 8
- Joined: Mon Aug 28, 2006 3:23 pm
Re: Page Class Suffix in template code
I tried this code in Joomla 2.5.3 and the body class is empty. Is it working in latest J! or i have to use some different code?designsubway wrote:For Joomla 1.6 use this in the head:And then this for the <body> tag:Code: Select all
<?php $app = JFactory::getApplication('site'); $pageclass = & $app->getParams('com_content'); ?>
Code: Select all
<body class="<?php echo $pageclass ->get('pageclass_sfx'); ?>">
- LAMF
- Joomla! Guru
- Posts: 761
- Joined: Fri Jul 03, 2009 9:51 am
Re: Page Class Suffix in template code
This works just fine but if I have an article that is not linked to from any menu object how can I apply a page class-suffix to that article?
Is it possible at all?
Is it possible at all?
-
- Joomla! Apprentice
- Posts: 6
- Joined: Wed Nov 22, 2006 5:20 am
- Contact:
Re: Page Class Suffix in template code
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 ?>">