简体   繁体   English

Drupal 7新的自定义模板

[英]Drupal 7 new custom template

Our drupal developer left company, so now I'm learning it ) 我们的drupal开发人员离开了公司,所以现在我正在学习)

If I open any page editor in admin panel, I see 'custom template' selectbox. 如果在管理面板中打开任何页面编辑器,则会看到“自定义模板”选择框。 In file structure I have some page-- and node-- files with similar names. 在文件结构中,我有一些页面文件和节点文件具有相似的名称。 For example in select box there is item 'Full width template'. 例如,在选择框中有“全宽模板”项。 And there are node--custom--fullwidth.tpl.php and page--custom--fullwidth.tpl.php in file structure. 文件结构中有节点-custom-fullwidth.tpl.php和页面-custom-fullwidth.tpl.php。

So I need to create one more custom template but I can't find it in admin panel. 因此,我需要再创建一个自定义模板,但在管理面板中找不到它。 How to do it, tell me please. 怎么做,请告诉我。

Thanx! 谢谢!

I found it myself. 我自己找到的。 Go to structure-content types-manage fields. 转到结构-内容类型-管理字段。 There is a field - 'CUSTOM template'. 有一个字段-“自定义模板”。 There I need to add new one. 在那里,我需要添加一个新的。

Try to write this piece of code in your template.php file. 尝试在您的template.php文件中编写这段代码。

function yourthemename_preprocess_page(&$vars, $hook) {
    if (!empty($vars['node']) && !empty($vars['node']->type)) {
        $vars['theme_hook_suggestions'][] = 'page__node__' . $vars['node']->type;
    }
}

And then create the new custom template in side /sites/all/[theme]. 然后在/ sites / all / [theme]边创建新的自定义模板。 And then clear the cache once. 然后清除一次缓存。

I have tried it in Drupal 7.x and its working fine for me. 我已经在Drupal 7.x中尝试过它,并且对我来说很好用。

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

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