English 中文(简体)
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. :(

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.





相关问题
REST question: PUT one representation, GET a different one?

Short version of the question: Does "GET" at a particular URI need to match what was "PUT" to that URI? I think not. Here s why: Given that a resource is an abstract thing that is theoretically ...

Sending the variable s content to my mailbox in Python?

I have asked this question here about a Python command that fetches a URL of a web page and stores it in a variable. The first thing that I wanted to know then was whether or not the variable in this ...

SharePoint Multiple New Item Forms

I ve got a custom list with a custom content type. I m aware that when you create a new item you can see a drop down for the different content types on that list which I assume all have their own ...

Downloading pictures/Word documents using ASP.NET

If I put the following code: Response.ContentType = "image/jpeg" Response.AppendHeader("Content-Disposition", "attachment; filename=capitol.jpg") Response.WriteFile(MapPath("capitol.jpg"))...

Detecting custom folder content types in MOSS2007

Given an SPListItem representing a folder, I need to find out whether it has the builtin folder content type, or a custom folder content type (with additional fields). Here is what I do ...

热门标签