Monday, 04 May 2015 16:41

Drupal theming: front page block positions

Written by

A Discussion Drupal vs Joomla Theming

I think this might be my first post specifically about Drupal.  I’ve been using Drupal for a few years now, but as many know, I’ve been a Joomla guy for a lot longer.  One of the nice things about Drupal’s theming structure is their “content” is rendered as a regular block.  So, when you’re managing blocks in the admin panel, you can assign a contact form block to the content area block area, and it shows up right below it.  No need to tweak the template files create a new block area (in Joomla speak, a module position).

Let’s look at the code

This is what comes by default in your Drupal theme page.tpl.php template:


    <h1><?php print render($title); ?></h1>
    <?php print render($page['content']); ?>


This implies that all of your pages will be structured the same, with the title and content.

In some projects, I’ve written code like this, which determines whether it is the home page or not, then render the content blocks based on the answer.  You’ll see in my code, the front page will load the “homecontent” blocks.  The inside pages will render the page title first, then the standard “content” position.

I’ve written this so that it’s easy to add block areas or set up DIV’s around them for various CSS techniques.  Keep in mind that you can also use the “body.front” CSS prefix to single out the home page directly in your CSS, which is often a cleaner solution than below, depending on what you’re trying to achieve.


<?php if ($is_front): ?>
<?php print render($page['homecontent']); ?>
<?php endif; ?>

<?php if (!$is_front): ?>
    <h1><?php print render($title); ?></h1>
    <?php print render($page['content']); ?>
<?php endif; ?>


I hope this is helpful!  As always, if you know of a better way of doing something, please sound off in the comments below.  Likewise if you have a request for a different topic or tutorial.

Last modified on Monday, 04 May 2015 17:28

Latest Comments

Got a similar email that seemed suspicious. Ignored it and they even followed up today.
My organization received one of these emails from "Linda," but uses https://www.bestprosintown.com/p...
Hi Nate, I got the same email template from the same email address today and found you through a ...
Just received one today (16 Aug 2022) from "Mailchimp". Thanks for sharing!
Thanks for posting this. I just got one today. I was 99% sure it was a scam, and your post confirmed...


Design & Development

Wordpress, Drupal, Joomla
New custom websites
Bespoke themes and extensions
Redesigns, upgrades, migrations

Web Design & Development


Optimization & SEO

Let us optimize and manage your overall online presence. We offer full service monthly SEO as well as one-time projects.  

Optimization Plans & Pricing


Maintenance, Patching

White glove monthly backups, security updates, maintenance and testing for your Wordpress, Drupal, or Joomla site.

Maintenance Plans & Pricing


Email Newsletter

Bring your web & marketing performance to the next level: monthly blog post roundup via email.  

Stay in Touch!