<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://mydrupalblog.lhmdesign.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>My Drupal Blog - Creating Custom Regions - Comments</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions</link>
 <description>Comments for &quot;Creating Custom Regions&quot;</description>
 <language>en</language>
<item>
 <title>Hi, this tutorial was only</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-10984</link>
 <description>&lt;p&gt;Hi, this tutorial was only for 5.x themes - things are a bit different for Drupal 6.&lt;/p&gt;
&lt;p&gt;In Drupal 6 regions are now defined via the theme&#039;s .info file.  Drupal.org has a couple of good explanations of how to implement regions in a 6.x theme &lt;a href=&quot;http://drupal.org/node/171205#regions&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;http://drupal.org/node/171224&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
</description>
 <pubDate>Tue, 27 May 2008 04:56:39 -0700</pubDate>
 <dc:creator>Laurence</dc:creator>
 <guid isPermaLink="false">comment 10984 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Does this work in Drupal 6?</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-10965</link>
 <description>&lt;p&gt;Does this work in Drupal 6? Can&#039;t find the &quot;function nameoftheme_regions()&quot; in the php file?&lt;/p&gt;
</description>
 <pubDate>Thu, 22 May 2008 08:17:58 -0700</pubDate>
 <dc:creator>Guest</dc:creator>
 <guid isPermaLink="false">comment 10965 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>I&#039;ve been struggling with</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-6840</link>
 <description>&lt;p&gt;I&#039;ve been struggling with this and glad to find this page.&lt;/p&gt;
&lt;p&gt;I don&#039;t see how the region placement is done, exactly.&lt;/p&gt;
&lt;p&gt;MyTheme had primary links below the graphic (not at the top), and I want it to use NiceMenus.&lt;br /&gt;
So I guess I need to define a new region, put a Nice Menus block in it, &amp;amp; have the block inherit from primary links.&lt;br /&gt;
But how does it get the style information?&lt;br /&gt;
Your directions suggest creating a new div, e.g., sub_header, in page.tpl.php.&lt;br /&gt;
But style.css for my Theme already contains details on the div containing the existing primary links.&lt;br /&gt;
Is there a conflict? What to do?&lt;/p&gt;
</description>
 <pubDate>Wed, 21 Nov 2007 15:55:56 -0700</pubDate>
 <dc:creator>Puzzled</dc:creator>
 <guid isPermaLink="false">comment 6840 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Hello everyone
Matias -</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-191</link>
 <description>&lt;p&gt;Hello everyone&lt;/p&gt;
&lt;p&gt;Matias - thank you for the kind comment.&lt;/p&gt;
&lt;p&gt;Owen - you had it right first time when you were trying to add the function to garland&#039;s template.php file.  Garland doesn&#039;t have this function included so you will need to add the whole thing in yourself.  To do this, just open garland&#039;s template.php file and add the entire function, as it is written above, directly after the opening php tag (&#039;&amp;lt;?php&#039;).  Remember to replace the &#039;nameoftheme&#039; part with the actual name of your theme - in this case &#039;garland&#039;. Then just follow the other instructions to add the region to your page.tpl.php file, and you should be good to go. Let me know how it goes :)&lt;/p&gt;
</description>
 <pubDate>Thu, 28 Jun 2007 05:03:34 -0700</pubDate>
 <dc:creator>Laurence</dc:creator>
 <guid isPermaLink="false">comment 191 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Hi Laurence,
Just thought I</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-190</link>
 <description>&lt;p&gt;Hi Laurence,&lt;/p&gt;
&lt;p&gt;Just thought I would drop a quick note... I installed Drupal 5.1 and worked with the default themes... &lt;/p&gt;
&lt;p&gt;This meant I could not find a template.php file in them... at least the one I did find (in the garland theme) didn&#039;t have the &quot;nameoftheme_regions()&quot; function in it... So, I kept hunting until I found the &quot;engines/phptemplate/phptemplate.engine&quot; file. I then added the custom region to that.&lt;/p&gt;
&lt;p&gt;Is that what is supposed to happen? This way I now have the region added to all themes that use the phptemplate engine?&lt;/p&gt;
&lt;p&gt;Make sense? Your thoughts and wisdom would be kindly appreciate!&lt;br /&gt;
Owen&lt;/p&gt;
</description>
 <pubDate>Wed, 27 Jun 2007 15:49:48 -0700</pubDate>
 <dc:creator>Owen</dc:creator>
 <guid isPermaLink="false">comment 190 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Laurence you are the man</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-187</link>
 <description>&lt;p&gt;Laurence you are the man with the Drupal plan.&lt;/p&gt;
</description>
 <pubDate>Wed, 27 Jun 2007 08:44:55 -0700</pubDate>
 <dc:creator>Matias O.</dc:creator>
 <guid isPermaLink="false">comment 187 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Thanks Alexei, I appreciate</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-85</link>
 <description>&lt;p&gt;Thanks Alexei, I appreciate the comment :)&lt;/p&gt;
</description>
 <pubDate>Mon, 11 Jun 2007 04:04:35 -0700</pubDate>
 <dc:creator>Laurence</dc:creator>
 <guid isPermaLink="false">comment 85 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Join the SEO guy completely!</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-81</link>
 <description>&lt;p&gt;Join the SEO guy completely! Thank you very much Lawrence! I have beel looking for this - and here it is, in human language!&lt;br /&gt;
Again, my hearty thanks! God bless you man!&lt;/p&gt;
</description>
 <pubDate>Sun, 10 Jun 2007 11:23:51 -0700</pubDate>
 <dc:creator>Alexei Rayu</dc:creator>
 <guid isPermaLink="false">comment 81 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Hi Drupal SEO Guy - good</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-79</link>
 <description>&lt;p&gt;Hi Drupal SEO Guy - good name ;)  I&#039;m glad the tutorial helped you out.&lt;/p&gt;
</description>
 <pubDate>Sun, 10 Jun 2007 07:55:02 -0700</pubDate>
 <dc:creator>Laurence</dc:creator>
 <guid isPermaLink="false">comment 79 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Perfect! Exactly what I was</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comment-76</link>
 <description>&lt;p&gt;Perfect! Exactly what I was looking for. My question is, why aren&#039;t great tutorials like this available on drupal.org? Thanks, Laurence!&lt;/p&gt;
</description>
 <pubDate>Sat, 09 Jun 2007 18:07:18 -0700</pubDate>
 <dc:creator>Drupal SEO Guy</dc:creator>
 <guid isPermaLink="false">comment 76 at http://mydrupalblog.lhmdesign.com</guid>
</item>
<item>
 <title>Creating Custom Regions</title>
 <link>http://mydrupalblog.lhmdesign.com/creating-custom-regions</link>
 <description>&lt;p&gt;All Drupal themes you download will come with a number of pre-defined regions into which you can already place blocks (normally header, left-sidebar, content, right-sidebar, footer), but it can sometimes be useful to create your own.&lt;/p&gt;
&lt;p&gt;This can seem a little daunting at first, but it&#039;s really just a simple two-step process:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;step 1 - define the custom region in your template.php file&lt;/li&gt;
&lt;li&gt;step 2 - add the custom region to your page.tpl.php file&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, lets see how it works.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 1 - define the custom region in your template.php file&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;All themes should have a template.php file contained within the theme folder.&lt;/p&gt;
&lt;p&gt;Open the template.php file in your chosen editor and locate the function titled &#039;function nameoftheme_regions&#039; (where nameoftheme will be the name of the theme to which you are adding a custom region).  This will probably be the first function in the file, and should look something like this:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;function nameoftheme_regions() {&lt;br /&gt;&amp;nbsp; return array(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;header&amp;#039; =&amp;gt; t(&amp;#039;header&amp;#039;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;left&amp;#039; =&amp;gt; t(&amp;#039;left sidebar&amp;#039;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;content&amp;#039; =&amp;gt; t(&amp;#039;content&amp;#039;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;right&amp;#039; =&amp;gt; t(&amp;#039;right sidebar&amp;#039;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;footer&amp;#039; =&amp;gt; t(&amp;#039;footer&amp;#039;)&lt;br /&gt;&amp;nbsp; );&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Okay, now just add your custom region so that it looks like the pre-defined regions.&lt;!--break--&gt;&lt;/p&gt;
&lt;p&gt;For example, I&#039;ll add a custom region called &#039;sub header&#039;, which I&#039;ll position below the header region.&lt;/p&gt;
&lt;p&gt;To do this I just add the following line:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;#039;sub_header&amp;#039; =&amp;gt; t(&amp;#039;sub header&amp;#039;),&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;to the function, so that I get&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;function nameoftheme_regions() {&lt;br /&gt;&amp;nbsp; return array(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;header&amp;#039; =&amp;gt; t(&amp;#039;header&amp;#039;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;sub_header&amp;#039; =&amp;gt; t(&amp;#039;sub header&amp;#039;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;left&amp;#039; =&amp;gt; t(&amp;#039;left sidebar&amp;#039;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;content&amp;#039; =&amp;gt; t(&amp;#039;content&amp;#039;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;right&amp;#039; =&amp;gt; t(&amp;#039;right sidebar&amp;#039;),&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#039;footer&amp;#039; =&amp;gt; t(&amp;#039;footer&amp;#039;)&lt;br /&gt;&amp;nbsp; );&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Just remember&lt;/strong&gt; that the first part of this line &lt;strong&gt;must not&lt;/strong&gt; contain any spaces.  In this case I have used an underscore &#039;_&#039;, instead of a space, between sub and header (sub_header), so I&#039;m okay.&lt;/p&gt;
&lt;p&gt;That&#039;s step 1 sorted, so save your template.php file and continue on with step 2.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step 2 - add the custom region to your page.tpl.php file&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So far I have just defined the custom region.  Drupal knows that I want the custom region, but doesn&#039;t know where to put it.  So lets sort this out.&lt;/p&gt;
&lt;p&gt;Open your theme&#039;s page.tpl.php file in your chosen editor.&lt;/p&gt;
&lt;p&gt;This file contains the main chunk of structure for your site&#039;s pages.  &lt;/p&gt;
&lt;p&gt;Decide where you would like your custom region to appear.  In this case I&#039;m creating a custom region called &#039;sub header&#039;, so it kinda makes sense to have the custom region appear beneath the header!&lt;/p&gt;
&lt;p&gt;So, just add the following code where ever you want the region to appear (replacing sub_header with the name of your own custom region):&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;lt;div id=&amp;quot;sub_header&amp;quot;&amp;gt;&lt;br /&gt;&lt;font color=&quot;#000000&quot;&gt;&lt;font color=&quot;#0000BB&quot;&gt;&amp;lt;?php &lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;print &lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$sub_header ?&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;and save the file.&lt;/p&gt;
&lt;p&gt;Technically, I actually only need to use the code:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;font color=&quot;#000000&quot;&gt;&lt;font color=&quot;#0000BB&quot;&gt;&amp;lt;?php &lt;/font&gt;&lt;font color=&quot;#007700&quot;&gt;print &lt;/font&gt;&lt;font color=&quot;#0000BB&quot;&gt;$sub_header ?&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;but doing so makes it harder to manipulate the content within the region, so in this case I have placed the region within a div also called sub_header which will be more easily controlled from the style.css file. &lt;/p&gt;
&lt;p&gt;Well that&#039;s it, your new custom region is now ready for use.&lt;/p&gt;
&lt;p&gt;To check that it really is there, log in to your site and navigate to&lt;br /&gt;
Home &gt; Administer &gt; Site building &gt; Blocks &lt;/p&gt;
&lt;p&gt;You should see your custom region highlighted, and also listed as an option in the region drop-down selections for each block.&lt;/p&gt;
</description>
 <comments>http://mydrupalblog.lhmdesign.com/creating-custom-regions#comments</comments>
 <category domain="http://mydrupalblog.lhmdesign.com/topic/custom-regions">Custom Regions</category>
 <category domain="http://mydrupalblog.lhmdesign.com/taxonomy/term/1">Drupal</category>
 <category domain="http://mydrupalblog.lhmdesign.com/topic/drupal-theming">Drupal Theming</category>
 <category domain="http://mydrupalblog.lhmdesign.com/topic/page-tpl-php">page.tpl.php</category>
 <category domain="http://mydrupalblog.lhmdesign.com/topic/template-php">template.php</category>
 <pubDate>Mon, 21 May 2007 03:00:23 -0700</pubDate>
 <dc:creator>Laurence</dc:creator>
 <guid isPermaLink="false">18 at http://mydrupalblog.lhmdesign.com</guid>
</item>
</channel>
</rss>
