The Web Developer's Blog has been discontinued. I am now maintaining a new blog that is related to my company, Blue Piccadilly. The most popular articles from this blog (by monthly page views) have already been republished on the new blog, and indeed those original pages on this blog are being redirected to their new location. I'll probably keep these pages up here for a while. At least until the domain expires.

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

I know how hard it is to create a program. My friend also do have headache when he has already done running the program and then there is some changes or some additional input to be added. He found difficulties sometimes to locate the part that will be having some corrections or additional.

Nancy

Blog: broyeur de branches 

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: <i> <b> <cite> <code> <a>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.