Drupal 7中每种内容类型的页面模板:找不到. [英] Page Templates per Content Type in Drupal 7 : The requested page "/appl/?q=lawn" could not be found.

查看:48
本文介绍了Drupal 7中每种内容类型的页面模板:找不到.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要基于自定义内容类型开发页面模板,因为我不想使用page.tpl.php文件模板.

我已按照以下步骤为每种内容类型创建页面模板.我正在工作drupal 7 bartik主题

我的步骤是:
1.我在主题模板文件中添加了以下代码,如

I need to develop a page template based on the custom content type,because I don''t want to use the page.tpl.php file template.

I have followed the below steps for creating Page Templates per Content Type. I am working drupal 7 bartik theme

My steps are:
1.I have added below code in the theme template file like

function bartik_preprocess_page(&$vars) {
   if (isset($vars['node']->type)) {
      $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
   }
}


2.我创建了一个内容类型,名为草坪花园(机器名称:草坪)
3.我在主题模板文件夹下创建了一个页面模板(page--lawn.tpl.php)
4.我已经清除了缓存
5.在浏览器中输入网址,例如http://localhost/appl/?q = lawn(已禁用干净网址)& http://localhost/appl/lawn(启用了清洁网址)
6.找不到类似于所请求页面"/appl/?q = lawn"的页面显示.

请帮助我,并向我提供建议.预先感谢.


2.I have created a content type named as lawngarden (Machine name: lawn)
3.I have created a page template (page--lawn.tpl.php) under themes templates folder
4.I have clear the cache
5.Enter the url in browser like http://localhost/appl/?q=lawn(clean url''s disabled) & http://localhost/appl/lawn(clean url''s enabled)
6.The page displays like requested page "/appl/?q=lawn" could not be found.

Please help me and provide me with suggestions. Thanks in advance.

推荐答案

vars){ 如果(isset(
vars) { if (isset(


vars [' 节点']->类型)))
vars['node']->type)) {


vars [' theme_hook_suggestions'] [] = ' page __'.
vars['theme_hook_suggestions'][] = 'page__' .


这篇关于Drupal 7中每种内容类型的页面模板:找不到.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆