-
AuthorPosts
-
griiettner Friend
griiettner
- Join date:
- November 2008
- Posts:
- 18
- Downloads:
- 0
- Uploads:
- 2
- Thanks:
- 2
- Thanked:
- 20 times in 6 posts
December 17, 2012 at 6:55 pm #183181For several aesthetic reasons, there are many designers that try to make the looks of a home page different than the rest of the site and for this we can take advantage of some Joomla ready API’s…
[PHP]
<?php
$menu = $app->getMenu(); //Calling getMenu function from library
if ($menu->getActive() == $menu->getDefault()) : //If the page you are viewing is home add the following line
echo ‘<body id=”homepage”>’;
else: //If not home page add the following line
echo ‘<body>’;
endif;
?>
[/PHP]You can add this to templatestemplate_nametplsdefault.php or what ever other variation file that will be the home page of your website T3V3 based template
wnrdesign Friendwnrdesign
- Join date:
- July 2011
- Posts:
- 15
- Downloads:
- 0
- Uploads:
- 4
- Thanks:
- 2
- Thanked:
- 4 times in 1 posts
December 17, 2012 at 8:21 pm #476551Unfortunatly this throws an error in the template management in the most recent version of jat3v3
The layout cannot be loaded. There might be some errors in the layout file.
Any updates on this?
griiettner Friendgriiettner
- Join date:
- November 2008
- Posts:
- 18
- Downloads:
- 0
- Uploads:
- 2
- Thanks:
- 2
- Thanked:
- 20 times in 6 posts
December 17, 2012 at 9:57 pm #476562What template are you using, because I just did this change to Brisk template and worked…
wnrdesign Friendwnrdesign
- Join date:
- July 2011
- Posts:
- 15
- Downloads:
- 0
- Uploads:
- 4
- Thanks:
- 2
- Thanked:
- 4 times in 1 posts
December 17, 2012 at 9:58 pm #476563<em>@griiettner 351030 wrote:</em><blockquote>What template are you using, because I just did this change to Brisk template and worked…</blockquote>
The default t3blank template
griiettner Friendgriiettner
- Join date:
- November 2008
- Posts:
- 18
- Downloads:
- 0
- Uploads:
- 2
- Thanks:
- 2
- Thanked:
- 20 times in 6 posts
December 17, 2012 at 10:06 pm #476564Sorry,
there is something missing on the previous code I pasted before, it should be like
[PHP]
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu(); //Calling getMenu function from library
if ($menu->getActive() == $menu->getDefault()) : //If the page you are viewing is home add the following line
echo ‘<body id=”homepage”>’;
else: //If not home page add the following line
echo ‘<body>’;
endif; ?>
[/PHP]1 user says Thank You to griiettner for this useful post
wnrdesign Friendwnrdesign
- Join date:
- July 2011
- Posts:
- 15
- Downloads:
- 0
- Uploads:
- 4
- Thanks:
- 2
- Thanked:
- 4 times in 1 posts
December 17, 2012 at 10:08 pm #476565<em>@griiettner 351033 wrote:</em><blockquote>Sorry,
there is something missing on the previous code I pasted before, it should be like
[PHP]
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu(); //Calling getMenu function from library
if ($menu->getActive() == $menu->getDefault()) : //If the page you are viewing is home add the following line
echo ‘<body id=”homepage”>’;
else: //If not home page add the following line
echo ‘<body>’;
endif; ?>
[/PHP]</blockquote>This indeed did solve this issue 😉
zekazeka Friendzekazeka
- Join date:
- November 2012
- Posts:
- 8
- Downloads:
- 0
- Uploads:
- 1
- Thanked:
- 2 times in 1 posts
December 18, 2012 at 9:07 am #476627Hi and tnx for you tip!
I need almost the same need, but i want to assign page class sfx to body tag, for that i use code
[PHP]$menu =& JSite::getMenu();
$active = $menu->getActive();
$pageclass_sfx = ”;
$params = $menu->getParams( $active->id );
$class = $params->get( ‘pageclass_sfx’ );[/PHP]but i get errors in template manager.
Can you advise something?
Jeka
griiettner Friendgriiettner
- Join date:
- November 2008
- Posts:
- 18
- Downloads:
- 0
- Uploads:
- 2
- Thanks:
- 2
- Thanked:
- 20 times in 6 posts
December 18, 2012 at 6:29 pm #476689I’m not sure what template you are trying, but, I got no error using the same exact code you posted… it worked fine for me on JA_Blank template…
zekazeka Friendzekazeka
- Join date:
- November 2012
- Posts:
- 8
- Downloads:
- 0
- Uploads:
- 1
- Thanked:
- 2 times in 1 posts
December 18, 2012 at 6:54 pm #476691I also using ja_blank. It work great in frontend, but in backend (in template manager) i got message
.
Please, check this in your instalation.
griiettner Friendgriiettner
- Join date:
- November 2008
- Posts:
- 18
- Downloads:
- 0
- Uploads:
- 2
- Thanks:
- 2
- Thanked:
- 20 times in 6 posts
December 19, 2012 at 4:49 pm #476811Sorry, I could not replicate the error you are having on the admin area… what I can think now, is, maybe, one of the variables are being used by some other function on the template… try renaming the variables to something different, by adding some sort of suffix…
zekazeka Friendzekazeka
- Join date:
- November 2012
- Posts:
- 8
- Downloads:
- 0
- Uploads:
- 1
- Thanked:
- 2 times in 1 posts
December 19, 2012 at 8:37 pm #476823<em>@griiettner 351354 wrote:</em><blockquote>Sorry, I could not replicate the error you are having on the admin area… what I can think now, is, maybe, one of the variables are being used by some other function on the template… try renaming the variables to something different, by adding some sort of suffix…</blockquote>
Thank you for your help!
Here the code that work for me[PHP]<?php
$app = JFactory::getApplication();
$menu = $app->getMenu(); //Calling getMenu function from library
$active = $menu->getActive();
$pageclass_sfx = ”;
$params = $menu->getParams( $active->id );
$class = $params->get( ‘pageclass_sfx’ );if ($menu->getActive() == $menu->getDefault()) : //If the page you are viewing is home add the following line
echo ‘<body id=”homepage”>’;else: //If not home page add the following line
echo ‘<body id=”‘.$class.'”>’;
endif; ?>[/PHP]griiettner Friendgriiettner
- Join date:
- November 2008
- Posts:
- 18
- Downloads:
- 0
- Uploads:
- 2
- Thanks:
- 2
- Thanked:
- 20 times in 6 posts
December 19, 2012 at 11:49 pm #476834So… is this working for you now??
zekazeka Friendzekazeka
- Join date:
- November 2012
- Posts:
- 8
- Downloads:
- 0
- Uploads:
- 1
- Thanked:
- 2 times in 1 posts
December 20, 2012 at 8:13 am #476897griiettner, yes!
AuthorPostsViewing 13 posts - 1 through 13 (of 13 total)This topic contains 13 replies, has 3 voices, and was last updated by zekazeka 11 years, 11 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum
Change body tag class if on home page
Viewing 13 posts - 1 through 13 (of 13 total)