drupal分隔模板代码的页眉和页脚,包括 [英] drupal separating template code header and footer with include

查看:76
本文介绍了drupal分隔模板代码的页眉和页脚,包括的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个drupal模板,并尝试使用此模板

I'm creating a drupal template and tried using this

    <?php require "".base_path() . path_to_theme()."'/header.php'" ?>

它确实提供了正确的路径,但是它给出了正确的路径

and it does provide the right path, but it gave this

警告:require(/learn/learn_drupal/sites/all/themes/test_theme'/header.php'):无法打开流:require()中没有此类文件或目录(/Users/Devric/Sites/learn/learn_drupal/sites/all/themes/test_theme/templates/html.tpl.php).

Warning: require(/learn/learn_drupal/sites/all/themes/test_theme'/header.php'): failed to open stream: No such file or directory in require() (line 33 of /Users/Devric/Sites/learn/learn_drupal/sites/all/themes/test_theme/templates/html.tpl.php).

有人知道如何分隔代码吗?

anyone know how to separate the code?

推荐答案

如果我是我,我会读懂如何设置适当的Drupal主题.

If I were you I'd read up on how to set a proper Drupal theme.

首先在主题目录中构建一个模板文件夹.然后从根 modules/system/page.tpl.php modules/system/html.tpl.php 复制到此新模板文件夹.

Start by building a templates folder in your theme directory. Then copy over from the root modules/system/page.tpl.php and modules/system/html.tpl.php to this new templates folder.

这是您的主要主题文件.html.tpl.php包含标头中的所有内容(元标记等)以及起始和结束主体标记.

This is your main theme files. html.tpl.php contains everything in your header (meta tags etc) and your start and end body tags.

page.tpl.php是正文之间的内容,或者基本上是表示<?php print $ page;的内容所打印的内容.?> .

page.tpl.php is what goes in between the body, or basically what is printed where it says <?php print $page; ?>.

如果打开page.tpl.php文件,您将看到所有区域等.这是页面的轮廓.使用此代码可以使用硬代码或Drupal出色的块系统来整理所有页脚,页眉等.

If you open the page.tpl.php file you'll see all your regions etc. This is your page outline. Use this as to sort out any footers, headers etc using either hard code or Drupal's excellent block system.

如果您认为这样的页面应该有所帮助:

If you think of your page like this is should help:

html.tpl.php -> opens your html page
   - page.tpl.php -> any constant elements above the content
      - node.tpl.php -> the content
   - page.tpl.php -> any constant elements below the content
html.tpl.php -> closes your html page

您不需要设置自己的包含项,因为Drupal已经为您完成了所有这一切.这是一个陡峭的学习曲线,我确实很难从一开始就开始努力,但是没有意义的是不要以Drupal的方式进行操作,因为您正在失去使它成为如此出色的CMS的原因.

You don't need to set up your own includes because Drupal already does all this for you. It's a steep learning curve and I really struggled to start off with but there's no point not doing things the Drupal way as you're losing what makes it such a good CMS.

您可以在此处了解更多信息- http://drupal.org/documentation/theme

You can read more here - http://drupal.org/documentation/theme

您可以将块设置为特定于页面,然后对其进行主题设置.例如,设置一个称为about header的块,并将其设置为仅显示在块管理页面中您想要的页面上.您可以按照与节点相同的方式为每个块设置模板.

You can set up blocks to be page specific and then theme them. Set up a block called about header for example and set to only be displayed on the pages you want it on in the blocks admin page. You can set templates up for each block in the same way you do nodes.

这篇关于drupal分隔模板代码的页眉和页脚,包括的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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