开发者

Drupal 6: Drupal Themer gives same candidate name for different type of content types

I'm a drupal newbie...

I have different type of contents like News, Events, etc. and their content is different. News detail page has title-content text-date. but Events detail page has title-date-content text-location-speaker-etc. So I need different layout page for these different types. So, I enabled Drupal Themer to get a candidate name. for events page, it gave me page-node.tpl.php and it gives same for News page as well :( how can I separate these pages? I expected sth like page-event-node.tpl , but no... :/ Drupal Themer also give unique candidate name for event page like page-node-18.tpl.php but it doesnt mean anything since I can not create a general layout for all events by this node name.开发者_JS百科 :(

Appreciate helps so much!! Thanks a lot!!!


While using different node.tpl.php files as suggested by monkeyninja (+1) would be the 'normal' way, you could add the functionality you want by adding page template suggestions based on node type yourself, in a preprocess_page function within a custom module/theme:

function yourModuleOrTheme_preprocess_page(&$variables) {
  // If this is a node page, add a page template suggestion based on node type
  if (isset($variables['node'])) {
    // Build the suggestion name ('.tpl.php' suffix will be added by the theming system)
    $suggestion = 'page-type-' . $variables['node']->type;
    // Add to end of suggestion array, thus keeping the fallback to other suggestions,
    // if this specific version is not implemented by the theme
    $variables['template_files'][] = $suggestion;
  }
} 

With this in place, you should be able to add e.g. a 'page-type-event.tpl.php' file, which should be used for all event node pages.

(NOTE: You'll need to trigger a rebuild of the theme registry after adding that function to get it recognized by the system)


I'm not familiar with Drupal Themer, but a slightly different approach would be to work with the node templates to style the content and use something like the excellent Context module (and possibly Panels module) to change the layout of any additional information on the page (eg the blocks).

To theme the different content types using node templates, just create templates based on node.tpl.php in the form node-content_type.tpl.php. So you'd have a template for your events nodes called node-events.tpl.php.

You could then define a context using the Context module that reacted when a page of the events content type was displayed and select which regions/blocks you wanted displayed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜