One interesting method of making a home page that offers a mix of easy editing of static fields, plus the ability to embed blocks and other dynamic content, is by making your front page using CCK. This might be a good choice if what you're after is an easily editable set of pre-defined fields (which would, for instance, make it easy for your non-tech-savvy client to edit basic static information without coding anything) with additional dynamic content drawn in through embedded Regions/blocks or Views.
Home, and Type to home.Body from the Body field label setting. If the label is empty, the Body field will not be included.Promoted to front page and set the Attachments option to Disabled.Disabled.
Home. Scroll to the bottom of the page and click "Submit configuration".<h1 class="title"><?php print $title; ?></h1> (or something similar, containing $title).<?php if (!$is_front) : ?>
<h1 class="title"><?php print $title; ?></h1>
<?php endif; ?>You can set up permissions so that only the admin (user 1) ever sees "Home" as an available content type on the Create Content page. Of course you only want "one" Home page, so it doesn't make sense to be shown the option to make more Home pages.
[note: will migrate the below section about embedding Blocks, Regions, and Views into template files to a separate dedicated article, and reference it from this page]
There are a variety of ways to easily embed dynamic content into your node-home.tpl.php file.
The following uses the default Search block as an example, to illustrate the technique for embedding any Block:
<?php
$block = module_invoke('search', 'block', 'view', 0);
print $block['subject'];
print $block['content'];
?>There are just 2 parts to the above code that you need to customize in order to display any particular block, which are highlighted in the sample below:
$block = module_invoke('search', 'block', 'view', 0);
You can embed any default or custom Region (populated with as many Blocks as you wish, which you can control and arrange at Administer > Site building > Blocks).
When you add custom Regions to your theme you have to include the default regions as well or they will no longer be used (you can, however leave out any that you don't want to keep). Add as many custom Regions as you wish. The following is for Drupal 6.
First add the Region(s) to your ThemeName.info file:
regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[home_custom] = Custom home region nameThen you can use the following code in node-home.tpl.php:
<?php print theme('blocks', 'home_custom'); ?>You can embed a View if it has a Block display using the Region method above. However it's also very easy to embed a View directly into the node-home.tpl.php file. (I need to check if this is true, but I believe a benefit of directly embedding a View instead of defining extra Regions is that it has better performance for your site). Here is info on embedding Views with Drupal 5. The following illustrates how to embed a View using Views 2 with Drupal 6 (more advanced options are also available):
<?php
$view = views_get_view('viewname');
print $view->preview('default');
?>Where viewname is the name of your View, and default can be changed to the page_# or block_# of any Display in your View. For instance, to embed the first Block Display defined in the View, you could use block_1.
The following is an example extracted from the node-home.tpl.php of absolutecross.com, which is currently being redeveloped in Drupal. It is made up of 3 custom text fields, and will soon add 2 embedded Views as well:
<div id="home_left">
<?php print $node->field_home_welcome[0]['view'] ?>
<?php print $node->field_home_featured_content[0]['view'] ?>
</div>
<div id="home_right">
<?php print $node->field_home_featured_sites[0]['view'] ?>
</div>