Reputation: 2600
I'm creating a Joomla 1.6 template and I would like to make the first page different from the others (I say, the others with articles). What I expect is something like it:
<?php
if(this_page_link_to_an_artcile || this_page_is_not_the_main) {
?> <jdoc:include type="component" /> <?php
}
?>
I looked in one of the standard templates and got somewhat lost trying to find the "if" which makes not be showed in some pages.
Upvotes: 0
Views: 3946
Reputation: 31
If you want to have individual styling for each page, or a group of page, then you can add this into your template index.php /head:
<?php $active = JFactory::getApplication()->getMenu()->getActive();?>
After that, make a wrapper div that covers all your page in the body tags, for example:
<body>
<div class="<?php echo $active->alias; ?> ">
----- PAGE CONTENT-----
</div>
</body>
That way you get to style any page you want with individual styling. For example, for "home" page, in you css file you should set properties for
.home .footer {}
to set properties for the .footer div that only appears on the home page.
Upvotes: 3
Reputation: 4711
// Is Frontpage?
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$frontpage = ($option == 'com_content' && $view == 'featured')
$is_article = ($option == 'com_content');
if ($is_article && !$frontpage)
{
// ...
}
(EDIT: now works in Joomla! 1.6)
($is_article || !$frontpage
should always return true ... because if it is not an article, it is not the frontpage. Depends on how you define "is an article", of course.)
Upvotes: 1
Reputation: 10609
What do you mean by different? Pages within Joomla look different based on which component and modules are being loaded. What content do you plan to have on your home page? You probably just need to change the default menu to a different type.
Unless there is a structural difference on the home page there is no need add more code, just change the menu type.
In order to accomodate structural difference from one page to another you need to make collapsible positions that only display when needed.
<?php if ($this->countModules('left')) : ?>
<div id="leftcolumn">
<jdoc:include type="modules" name="left" style="xhtml" />
</div>
<?php endif; ?>
You will also want to take advantage of the page class suffix parameter you can add to menu items. This allows you to add styles that are page specific. I usually add it to the BODY tag in my template index.php.
<?php
$menu = &JSite::getMenu();
$active = $menu->getActive();
$pageclass = "";
if (is_object( $active )) :
$params = new JParameter( $active->params );
$pageclass = $params->get( 'pageclass_sfx' );
endif;
?>
<body id="<?php echo $pageclass ? $pageclass : 'default'; ?>">
Upvotes: 0
Reputation: 263
You can have multiple templates with joomla, and assign them to different menu items / pages. You can for example have your main template (with articles) and another template only for the home page, that is ex. linked to "Home" menu item.
You can do the menu item/template assignment with the Template Manager.
Upvotes: 1