【发布时间】:2013-09-23 06:27:51
【问题描述】:
我的网站中有 8 种内容类型,其中 4 种具有相同的结构,不同之处只是它们的名称。我想为他们创建一个节点页面,但我想为每个页面创建一个 .tpl.php 文件效率低下。我使用以下方法为某种内容类型创建节点页面:
创建页面并重命名为page--node--Machine-Name-of-ContentType.tpl.php
-
将此函数添加到template.php
function ThemeName_preprocess_page(&$variables) {
if (isset($variables['node'])) { $suggest = "page__node__{$variables['node']->type}"; $variables['theme_hook_suggestions'][] = $suggest; }}
有没有办法为多种内容类型创建一个节点页面?
【问题讨论】:
标签: templates preprocessor content-type