Since redesigning this site, I've been getting a ton of requests for Drupal theme design. Most of the projects are too small for me to take or require too much work for the amount of money people have budgeted. So to help people who are new to doing theme design with Drupal, I'm going to start a series of tips on getting more out of your Drupal themes. My focus will be on using the PHP Template engine for my examples because it's the best option for flexibility of your theme design. I should note that not all tips will be theme specific, however. This first tip is really about re-using content blocks in pages.
The portal model
Some of you may be familiar with the concept of portlets inside portals like Oracle Portal or some such. Portlets are little windows of content that you insert into a portal page. So you might have a page on a topic, e.g. Human Resources in your portal. But to populate that page, you may take existing content from other sections of your portal. To do this, you select a portlet from your admin menu and tell your portal page to use it. You typically select a bunch of these to build up a page's content.
In Drupal we can do similar things to populate content, but this type of modular approach to individual page building is usually left to content management systems like Mambo/Joomla and the commercial portal CMS's. To stack blocks of content in Drupal, we need to do a little more work and take a few more steps, but it's doable. One approach is to build your content modules within Drupal's block system. And then when you create a new page (has to be a PHP page), you simply insert block calls into your page body.
Here's an example showing how a typical portal page is built and how you might build a Drupal page with blocks in a similar manner:

So you see that what I plan to do is display a block using PHP. To give you an example, let's take a to do list. I'm a fan of the GTD method of time management, so I created a new "To do items" content type using flexinode. Taking that example in the diagram above, I want to insert a block of my latest to do items in a content area on the left, and a list of new links I've tracked in a content area on the right.
Inserting blocks in Drupal pages
To insert the blocks, we use some PHP code in the page body and be sure to select "PHP code" for the Input format. (More on this technique in the Drupal node: Placing the contents of a block in any location.)
PHP code to insert my to do list
For this content area, I created a block that does an SQL search for my to flexinode-5 items. Then I use the module_invoke() function to display the block within the page. Note that "7" is the ID number of the block I created in the admin -> blocks menu.
<?php
$block = module_invoke('block', 'block', 'view', 7);
print $block['content'];
?>
Alternatively I can simply insert the PHP with the SQL statement into the page itself like so:
<?php
$sql = "SELECT node.title, node.nid FROM node WHERE type='flexinode-5' ORDER BY node.created DESC LIMIT 50" ;
$output .= "<ul>";
$result = db_query($sql);
while ($anode = db_fetch_object($result)) {
$output .= "<li>".l($anode->title, "node/$anode->nid")."</li>";
}
$output .= "</ul>";
$output .='<div class="more-link"><a href="to_do_list" class="small">more</a></div>';
print $output;
?>
Displays this:
PHP code to insert latest blog entries
<?php
$block = module_invoke('blog', 'block', 'view', '0');
print $block['content'];
?>
Displays this:
- Temple Grandin: The world needs all kinds of minds
- Reading Flash with Drupal (Free Download: Chapter 10 on User Management)
- Bookmarklet to save to both del.icio.us & Evernote
- Konigi Wireframe Icons: Royalty Free EPS and PNG
- ToneMatrix
- idaft
- Jorge Colombo | iSketches
- Make a bag
- THRU YOU | Kutiman mixes YouTube
- WebEnabled Offers Software Sales Platform and Marketplace
Wrapping it up
That's it really. You can then use CSS to format your columnar layout. Very simple method to get near portal-like functionality. Might be nice if the "Page" content type used the content management model so we select blocks of content from within the "Create" interface and move the blocks around. That would require an entirely new administration UI, however.If you get comfortable with the method above, this might be a suitable approach for re-using content in pages. This is one method I would definitely try using in client's sites, but your site administrator will have to be familiar with PHP to create these kinds of blocks. Anyone who's wanting this kind of functionality and who is not comfortable touching PHP might be better served by other CMS packages.