0

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!

  • yes, Theming is important part of drupal sites – TBI Infotech Aug 5 '14 at 8:13
1

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.

  1. node--article.php, if you have the same header and footer content and just content part design is different.
  2. page--article.php (page–[node-type].tpl.php), Here you can customize the content part as well as different layout for header and footer part.

Also there will a customization option in the manage display part of the content type.

Hope it will help you.

  • Thank you. This is a more simple and direct approach. :) – nathanie0221 Sep 5 '14 at 7:40
0

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?

  • Thanks for the answer using $is_front also helps. :) – nathanie0221 Sep 5 '14 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.