德鲁帕尔 6 : Drupal Themer gives same candidate name for different type of content types

标签 drupal drupal-6 content-type drupal-theming

我是 drupal 新手...

我有不同类型的内容,如新闻、事件等,它们的内容也不同。新闻详细信息页面有标题-内容文本-日期。但事件详细信息页面有标题-日期-内容文本-位置-演讲者等。所以我需要针对这些不同类型的不同布局页面。因此,我启用了 Drupal Themer 来获取候选名称。对于事件页面,它给了我 page-node.tpl.php ,它也为新闻页面提供了相同的信息:(我如何分离这些页面?我期望像 page-event- node.tpl ,但没有...:/Drupal Themer 还为事件页面提供了唯一的候选名称,例如 page-node-18.tpl.php 但这并不意味着任何事情,因为我可以不通过此节点名称为所有事件创建通用布局。:(

感谢有很大帮助!!非常感谢!!!

最佳答案

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

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;
  }
} 

完成此操作后,您应该能够添加例如一个“page-type-event.tpl.php”文件,该文件应用于所有事件节点页面。

(注意:添加该函数后,您需要 trigger a rebuild of the theme registry 才能被系统识别)

关于德鲁帕尔 6 : Drupal Themer gives same candidate name for different type of content types,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2964811/

相关文章:

javascript - 在表单提交时运行 JavaScript 代码

c# - 上传 blockblob 并设置 contenttype

php - Drupal 安装问题。奇怪的错误

php - 如何在 drupal 中显示分类的 View 中添加自定义链接

php - 如何以编程方式将 css 类添加到一段代码中?

forms - Drupal 8 自定义表单错误

drupal-6 - PHP 弃用了 Drupal 页面上的警告,尽管在 php.ini 中将其关闭

drupal - 在 Drupal 安装中,如何重新发送用户的激活电子邮件

c# - 如何跨操作系统接受具有指定内容类型的文件

Azure Blob - 是否有查询字符串选项来指定内容类型?