Create new template positions for block placement

13-Nov-2007
Filed under: Drupal, Drupal 5.x

This little trick will let you create new template positions for your page.tpl.php, which you can use as containers for your blocks.

Add the following snippet to your template.php:

<?php
function mytemplate_regions() {
  return array(
          
'left' => t('left sidebar'),
          
'right' => t('right sidebar'),
          
'content' => t('content'),
          
'header' => t('header'),
          
'footer' => t('footer'),
          
'myposition' => t('my position name'),
  );
}
?>

Now replace 'mytemplate' with the name of your own template, and replace 'myposition' and 'my position name' with the details of your new template position. 'myposition' will become the variable name to place in page.tpl.php, e.g.:

<?php print $myposition ?>

'my position name' is the descriptive name of the position that will appear in the Region dropdown list on the blocks configuration page.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Comment spam will be deleted.

This includes any comment posted here for the sole purpose of increasing your page rank. You're wasting my time and your own.