Last updated December 4, 2009. Created by jbrauer on October 6, 2006.
Edited by alotronic, WillieBHines. Log in to edit this page.
The Lullabots suggested this one: If you want a custom front page, one way to do it is to use the Content Creation Kit. Basically, you make a custom content type which you will use only for your front page.
- Make a new content type called "home."
- Define a field for each area of your front page: "tip of the day", "about the site", whatever. Probably all text fields.
- Create a "node-home.tpl.php" file. Remember, when Drupal is showing CCK nodes, it automatically looks for a node--NAMEOFTYPE.tpl.php file. So you don't need to change template.php.
- Format each field that you defined. If you created a field called "tip of day", you would do this...
- Then create one node of this type and make it your front page. Like if it's node 34 you go to Administer->General Settings>Default Front Page and set that to "node/34" You could theoretically make other nodes of this type but the idea is that you're only going to need one node.
<div id="custom_html_div">
<h2>Tip of the Day<h2>
<?php print $node->field_tip_of_day[0]['view']; ?>
</div>You can get a list of what your fields are named by going to the "manage fields" tab under administer->content->content types.
Now when authorized users/authors come to the site, they should see an "edit" tab right on the front page, letting them change each section easily. And you have a separate .tpl.php file for your front page. Handy!
You can still mix in blocks. Print an existing region like this:
<?php print theme('blocks', 'left_sidebar'); ?>Or a custom region:
<?php print theme('blocks', 'home_page_region'); ?>Refinements - using CCK field variables to customise output
Various CCK fields have different field variables you can take advantage of in place of ['view']. For example on an Image CCK field you can use ['filepath'] to print the file path instead of the complete image tag. The quick way to see what variables you have to play with is to put somewhere obvious in your template page:
<?php
print_r($node)
?>You can also use the contemplate module for the same ends.