Adding an editable area to drupal

I have a theme thats working great but I want to add a new block region so I can edit an area from within the admin / not having to open template files to alter.

No votes yet

Replies

Drupal Regions

In your templatename.info file you should have something like this

regions[left] = left sidebar
regions[right] = right sidebar
regions[content] = content
regions[header] = header
regions[footer] = footer

Then in your template files (page.tpl.php) these areas are printed out like this (For the left sidebar)

<?php
if ($left):
?>

<?php
print $left
?>

<?php
endif;
?>

To add a region just add the line

regions[example] = example region

The left defines the region the right is just a description that will be seen from the admin area blocks.

Now in your page.tpl.php add

<?php
if ($example):
?>

<?php
print $example
?>

<?php
endif;
?>

Your rating: None

Post new comment

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

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.