How do you work with regions if your website has different page layouts? For instance, the home page is a header-content-footer page, while the article page is header-sidebar-content-footer, etc.
Learning themeing :)
Thanks!
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityHow do you work with regions if your website has different page layouts? For instance, the home page is a header-content-footer page, while the article page is header-sidebar-content-footer, etc.
Learning themeing :)
Thanks!
You can do it by creating templates for different types of pages.
e.g. If you have different layouts for front page, you can create page--front.tpl.php. It will work for front page only, for rest of the pages page.tpl.php will work.
If further you have different layouts for page types, e.g a normal layout for pages and different layouts for article type of pages then you can create two types of tpl.
Also there will a customization option in the manage display part of the content type.
Hope it will help you.
Different page layouts are usually created by themeing the main page.tpl.
So if your front page is different, it is likely your theme is using a page--front.tpl.php to override the look of the front page.
You can also hide regions if they are on the front page by checking if $is_front...
This checks if it is the front page, and then makes sure there is content in the front_welcome region, before printing that region.
<?php if ($is_front): ?>
<div class="container">
<?php if ($page['front_welcome']): ?>
<div id="front-welcome"> <?php print render($page['front_welcome']); ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
You can also check if other regions have content, before printing regions on other parts of the page, and assigning classes to other regions...
In this example in one of my themes, I work out if one, or two sidebars are being used, and print a class for the main content to determine the contents width with CSS...
<?php if($page['sidebar_first'] && $page['sidebar_second']) {
$contentwid= "seventeen";
} elseif($page['sidebar_first'] || $page['sidebar_second']) {
$contentwid= "eleven";
} else {
$contentwid= "sixteen";
} ?>
<div id="content" class="<?php print $contentwid; ?> columns">
</div>
Does that help at all?