I literally just started touching drupal this morning, and I'm sort of in a rush to learn how to use it for theme development. I could really use some help here.

I've figured out how to create the basic overides for stuff like the html.tpl.php and page.tpl.php and so forth, but I'm confused as to how to create template files for a specific page. I've found the naming conventions of page-node-#.tpl.php and the like but it doesn't seem to work. I recognized it as being the same priciple as WordPress but it looks like I'm wrong. I'm also confused because I'm getting the impression 7 is significantly different from 6 and the only tuts I can find are for 6.

Mainly, I want to adjust the home page so it displays the content I've written for it, as well as the latest entry of a particular custom content type. Can I pull this off right in the structure settings or does this indeed require a custom template file? Everything else I just want to streamline and shave down the excess nested divs.

Thanks, I can work magic with WordPress but diving into Drupal is knocking me down a few dozen pegs.

Comments

francort’s picture

1) For page override

You'll need to say your theme to take control with the right template.
At this time on D7 , it doesn't look for the page-content-type by itself.

So , on your template.php(theme file) implement this hook(copy this somewhere on the file):

/**
 * Implements hook_preprocess_page().
 */
function <YourTheme>_preprocess_page(&$vars, $hook) {
  if (isset($vars['node'])) {
   $vars['theme_hook_suggestions'][] = 'page__'. str_replace('_', '--', $vars['node']->type);
  }
}

..then clear cache (admin/config/development/performance)

and now, your theme will recognize files like:
page--miNodeType.tpl.php

for the front page, you have it without any new function. It always has been:
page--front.tpl.php

2) For extra content on front page
If you need to show something extra on your front page, you may use a block made with views module(still on alpha release, but I'm sure it will do this trick) or a custom block(you may enable php filter module, and play with drupal api/custom php). Then you just configure the region in which you want it and in which pages you want it.

Drupal takes some time to learn it and D7 is still new, so the documentation isn't on its best stage yet.

cheers,

Zonglars’s picture

Thanks! That should do the trick, really appreciate it francort!