I've figured out how to create conditional for content to appear based on whether the user is on the 'frontpage' or not, but how do you do it for any other page.
For example:
I want my 'main content' component to appear in one div on the frontpage, yet on another when I click on the "articles" link. This in order to achieve different widths for each. Are the names of the other "pages" custom...in otherwords can refer to them with the section name?
PHP conditional based on page/section other than 'frontpage'
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
Re: PHP conditional based on page/section other than 'frontpage'
You could use two separate templates.
Also, if you know if the visitor is on the front page, can you not reverse that check to determine when you are not on the front page?
Also, if you know if the visitor is on the front page, can you not reverse that check to determine when you are not on the front page?
http://springhillalumni.org • Springhill High School Alumni Association
Re: PHP conditional based on page/section other than 'frontpage'
Yes I can, but I can't distinguish between various secondary pages:
Example:
if page==blog...or could be if section==blog {show this}
Is that clearer?
Example:
if page==blog...or could be if section==blog {show this}
Is that clearer?
- AmyStephen
- Joomla! Guru
- Posts: 579
- Joined: Wed Nov 22, 2006 3:35 pm
- Location: Nebraska
- Contact:
Re: PHP conditional based on page/section other than 'frontpage'
You can look at the global variable $Itemid, a value associated with the menu item (it can be seen on the menu item line.)
Typically, it's a good idea to layout your menu item pages in a grid, then consider where all of your modules and component will go. Frequently, that knowledge is all that is needed to conditionally hide or show modules in the template.
Rarely do template designers create an entire template page for each menu item. But, if you do, then you should consider using the Template Manager to assign your various looks to the menu items. That way, you can keep the index.php files simpler.
Hope that helps!
Amy
Typically, it's a good idea to layout your menu item pages in a grid, then consider where all of your modules and component will go. Frequently, that knowledge is all that is needed to conditionally hide or show modules in the template.
Rarely do template designers create an entire template page for each menu item. But, if you do, then you should consider using the Template Manager to assign your various looks to the menu items. That way, you can keep the index.php files simpler.
Hope that helps!
Amy
~*~ Joomla!'s Queen of the Blues - Jennifer Marriott ~*~
http://OpenSourceCommunity.org/node/1719/
http://OpenSourceCommunity.org/node/1719/
Re: PHP conditional based on page/section other than 'frontpage'
Thanks. That should work.
Can you also refer to the id on in php conditional just as much as you can refer to the view?
Can you also refer to the id on in php conditional just as much as you can refer to the view?
Last edited by lexpresso on Sun Oct 28, 2007 2:38 am, edited 1 time in total.
- AmyStephen
- Joomla! Guru
- Posts: 579
- Joined: Wed Nov 22, 2006 3:35 pm
- Location: Nebraska
- Contact:
Re: PHP conditional based on page/section other than 'frontpage'
lexpresso wrote:Can you also refer to the id on in php conditional just as much as you can refer to the view?
Yes, you certainly can! Here's an example:
Code: Select all
<?php If ($Itemid == 23) { ?>
do something
<?php } ?>
Good luck with your work,
Amy
~*~ Joomla!'s Queen of the Blues - Jennifer Marriott ~*~
http://OpenSourceCommunity.org/node/1719/
http://OpenSourceCommunity.org/node/1719/