Blog

How to add Regions to your Zen Base Theme

Introduction

Base themes are great and the documentation supplied with Zen is the best.
In addition the Zen Gardens website which illustrates many example sites based around the Zen Starter Kit, but goes one step further to include the CSS code so you can learn more.

However, only a limited number of Drupal Regions are available in the starter kit. Such as Header, Footer, Left and Right and you need more than that in your new Drupal website.

For instance most sites you like the layout of have a set of Footer Positions which enable a neat summary at the base of the site with links to other sites, or links to interesting aspects of your website. Chances are that this would be 4 or 5 Boxes at the bottom. Of course it’s for SEO purposes and these would contain relevant related Anchor Text tags too.  These are also a pleasant reminder to your website visitors what’s on offer at your site as they proceed to scroll down to the bottom of the page.

Maybe you need to same elements available at the top of the site too. You can do this easily with Drupal and the Zen Starter Theme.

Overview

This article supplies example code that may be of some value as you learn the methods associated with Drupal Themes.  Often Drupal related documentation focuses in on Theming of particular Node or Page – but you just want a template with some common options at present.

Today’s article focuses on the Back Bone specifics of adding new regions and uses CSS to represent these regions to automatically scale in pixel percentage across the page in the form of elements. This depends on how many elements (Drupal speak Regions) are published for that page. So it’s neat and scales to cater for your published content as well. However typically the Footer Region will not need this function.  But like all good things Drupal, it can do this too!

File Modifications Required

Lets assume we are going to add 5 New Regions to a Footer area at the base of the site and the site uses the Fixed  Template supplied in the Starter Kit. (I don’t talk about fluid layouts)
-    Xxx.info file
-    Layout_fixed.css
-    Page.tpl.php
These are presented so you know the areas that are required. What do they do and where can they we found in the Zen Template Starter Kit is discussed below.  Also code snippets to send you on you way.

xxx.info
Located in the root directory of the Starter kit. Call it what ever you like, but follow the instructions in the readme.text files.  Sufficient documentation is already available to create a new Zen based Starter Theme and name it ‘foo’ and that’s not today’s focus.
xxx.info defines the new regions and makes this information available to Drupal core.
Add this code into the file
regions[bottom_first] = bottom_First
regions[bottom_second] = bottom_Second
regions[bottom_third] = bottom_Third
regions[bottom_fourth] = bottom_Fourth
regions[bottom_fifth] = bottom_Fifth


This is the starting point of adding 5 new regions in the footer area.

Page.tpl.php
Located in the Templates folder of the Zen Starter Kit find the page.tpl.php file as we need to add some php snippets to call and screen print data from the database. Where you place this is important and to achieved the desired result in this instance would be to place this code directly beneath the following statements

<?php print $sidebar_first; ?>

<?php print $sidebar_second; ?>

</div></div> <!-- /#main, /#main-wrapper -->

Cut and paste this stuff…..

<?php if($bottom_first || $bottom_second || $bottom_third || $bottom_fourth || $bottom_fifth): ?>
<div style="clear:both"></div>
<div id="bottom-teaser" class="in<?php print (bool) $bottom_first + (bool) $bottom_second + (bool) $bottom_third + (bool) $bottom_fourth + (bool) $bottom_fifth;?>">
<?php if($bottom_first) : ?>
<div class="column A">
<?php print $bottom_first; ?>
</div>
<?php endif; ?>
<?php if($bottom_second) : ?>
<div class="column B">
<?php print $bottom_second; ?>
</div>
<?php endif; ?>
<?php if($bottom_third) : ?>
<div class="column C">
<?php print $bottom_third; ?>
</div> 
<?php endif; ?>
<?php if($bottom_fourth) : ?>
<div class="column D">
<?php print $bottom_fourth; ?>
</div> 
<?php endif; ?>
<?php if($bottom_fifth) : ?>
<div class="column E">
<?php print $bottom_fifth; ?>
</div> 
<?php endif; ?>
<div style="clear:both"></div>
</div>
<?php endif; ?>


Layout_fixed.css
This file is located in the Zen Starter Kit folder and specifically beneath the CSS directory.

Cut and paste this code to ensure the new positions present themselves across the page and scale automatically
Cut and past this code….

-------------------------------------------------------------- */

#bottom-teaser {
width:960px;
margin: 10px auto 10px; font-size: 10px;
}

#bottom-teaser .column {
float: left;
}

#bottom-teaser.in1 .column {
width: 100%;
}

#bottom-teaser.in2 .column {
width: 50%;
}

#bottom-teaser.in3 .column {
width: 33%;
}

#bottom-teaser.in4 .column {
width: 25%;
}

#bottom-teaser.in5 .column {
width: 20%;
}

#bottom-teaser .block {
padding-left:15px;
padding-right:15px;
}
/* Bottom teaser-end - I added this
-------------------------------------------------------------- */

Conclusion

That’s about it.
You should be able to go back the Drupal Administrator and create 5 New Blocks and define these to appear in your newly created Drupal regions.

Good Luck and happy Drupal Theming

Views, Views, Views

What are Drupal Views and why this is a must do element in your Drupal website designs?

The Drupal Views Module is essentially a means of extracting content from your mySQL data base and presenting this in various formats on your website.  If this sounds a bit complex – well it is not.

The Views Module has a wonderful U.I. (user interface) whilst initially a little complex, after a short period of time you can be writing your own reports and presenting this data is several different formats on your Drupal website.

Concept

Create a single View that extracts the fields / elements that you need ie Title, Content etc from the database.  A default view is created for this, add additional view style elements such as Page or Block and further extend and customize these to suit. Construct a single View and use this in numerous formats and places with your website.

New to Drupal and from Joomla Background

Views replaces a heap of standard Joomla core functions, but it does give you the opportunity to customize each of these which previously could not do.

Lets say for instance that you like the Joomla Latest New Module, but wish to use this in the centre content position.  With Views this is straight forward basic, create the view that sources content from Content Type (Drupal speak) as opposed to Section, Category (Joomla Speak). Clone the default to the Page type, then define the presentation. Or you wish to limit the number of characters that appear on side bar view (ie Block View) to 77 characters, but not restrict the characters on the Page view.  All this is simply defined in your View settings for that type.  The View remains unchanged, the output per view type defines these aspects.

Views can be used as Pages or Blocks (Drupal speak) In Joomla these Blocks correspond to Joomla Module positions.

Views offer several standard output formats such as Page, Blocks, or RSS feed.  The key issues is that each View has a subset of output formats.

Create a View to gather content from your database, then present this on your website anywhere and anyway you wish.

Associated Drupal Modules

CCK Content Constructor Kit. Define Content Types to use in your Views.

Previous articles which described Straight Out of the Box (SOOTB) were a 1st glance at Drupal and how a minimal approach is used as a starting platform to expose new users to Drupal. However, to perform reasonable functions with Drupal one must source, download and install additional modules as building blocks for your new Drupal website. Drupal SOOTB is lean and mean and I think this was intended this way to allow you to only add modules which are required for your website.

Which modules should you have close look at that are installed by default?

Which modules are must have additional add in types available from Drupal?

As we are discussing appreciating Drupals Power today - I will skip past anything associated with Template Themes and Styles and focus on mechanics.

Taxonomy - Included

Learn how with Taxonomy your create Tags that collect content by specific type. Also how to create sub categories of these tag types.  As your website content grows - you will need to maintain some form of structure here.

CCK - Add In Modules

Content Constructor Kit lets you add additional fields to Content Types.  I mentioned in other articles that Drupal comes with two standard content types i.e. Story and Article. Their is so much more power to Drupal than simply these two.  Coupled with CCK, the creation of specific types of content for your website is an "open playing field" create your own, modify and enhance these to suit your requirements in terms of content definitions.

Views - Add In Modules

This offers so much power and flexibility to report writing. Whilst some what complex in its initial appearance - this tool highlights Drupals power.  Create a View, extract specific data from your database (with no mySQL knowledge) add filters and sorts etc.  Then use these set up View specifics to present the same content in a completely different format, and at same time retain the 1st. whew Views is great.

Summary

If your serious about exploring Drupal you are going to need around 10 or so add in modules to really get with the Drupal growd.  CKK and Views are in the top 5. So download and read the documentation for these.

 

Content Creation using Views - Getting this Installed

Moving forward and installing add in modules to expand Drupals functionality.

In this article we head down the path of installing the most highly used Drupal modules. The goal here is to “Get with the Drupal Crowd” and find out what modules they are using to create content and why. We’ll see that Drupal often evolves search, download, install, enable.  Following this success, then more search for documentation examples to implement. To kick things off - the most highly downloaded module from Drupal is Views – so what better place to start.

Read more...

Drupal is a huge resource - where do you start?

This really depends on your existing skill set and the goal for your website. I hope the following provides some insight.

As discussed in previous posts, we have installed Drupal and examined the key elements in Drupal sites such as Template Themes and Regions, Modules, Blocks, and basic content types such as Basic Page and Article.

Read more...

More Articles...

Page 1 of 2

Start
Prev
1