简体   繁体   English

Drupal 6:Drupal Themer为不同类型的内容类型提供相同的候选名称

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

I'm a drupal newbie... 我是Drupal新手...

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. 因此,我启用了Drupal Themer来获取候选名称。 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. :( 对于事件页面,它给了我page-node.tpl.php ,对于新闻页面也给了它:(我如何分隔这些页面?我期望像page-event-node.tpl一样 ,但是没有……: / Drupal Themer还为事件页面提供了唯一的候选名称,例如page-node-18.tpl.php,但这并不代表任何含义,因为我无法通过该节点名称为所有事件创建通用布局。

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: 虽然按照monkeyninja(+1)的建议使用不同的node.tpl.php文件是“正常”的方式,但您可以通过在自定义内的preprocess_page函数中根据节点类型自己添加页面模板建议来添加所需的功能模块/主题:

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 eg a 'page-type-event.tpl.php' file, which should be used for all event node pages. 使用此功能后,您应该能够添加例如“ page-type-event.tpl.php”文件,该文件应用于所有事件节点页面。

(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). 我不熟悉Drupal Themer,但是稍微不同的方法是使用节点模板来设置内容的样式,并使用出色的Context模块 (可能是Panels模块 )之类的东西来更改该模板上任何其他信息的布局。页面(例如,块)。

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. 要使用节点模板为不同的内容类型设置主题,只需基于node.tpl.php创建模板,格式为node-content_type.tpl.php。 So you'd have a template for your events nodes called node-events.tpl.php. 因此,您将拥有一个用于事件节点的模板,称为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. 然后,您可以使用上下文模块定义上下文,该上下文模块在显示事件内容类型的页面时做出反应,并选择要显示的区域/块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM