Community Documentation

Front page blocks for plain PHP themes

Last updated August 27, 2009. Created by lucsan on November 19, 2007.
Edited by bekasu, add1sun. Log in to edit this page.

I was able to add a front page block by editing the drupal.theme file in my plain PHP theme. This means if you are using a Chameleon clone (the one with the chameleon.theme file) all you have to do is add the new blocks reference to the yourtheme_regions() function, the block theme reference to the yourtheme_page function:

  // Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
  $blocks_left = theme_blocks('left');
  $blocks_right = theme_blocks('right');
  $blocks_home_center = theme_blocks('home_center');

then add the following code where you want your block to appear.
  $output .= "\n<!-- begin content -->\n";

  if ( $show_blocks && !empty($blocks_home_center) && drupal_is_front_page() ){
    $output .= "<div id=\"home_center\" class=\"home-center\">$blocks_home_center</div>";
  }

As you can see I put mine just after the begin content marker. For left and right blocks the areas in the theme file are clearly marked.

If this is a center block, you may also need to add a line to common.css after .block

.block {
  width: 180px;
}
#block-block-11{
width: 100%;
}

You will need to publish the block or hover over the configure in admin blocks to get the block number

About this page

Audience
Developers and coders, Themers

Theming Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.