You are here

2 默认的html.tpl.php模板文件

admin 的头像
Submitted by admin on 星期五, 2015-09-18 06:09

作者:老葛,北京亚艾元软件有限责任公司,http://www.yaiyuan.com

Drupal自带的默认html.tpl.php模板文件,位于modules\system目录下面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"

  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>

 

<head profile="<?php print $grddl_profile; ?>">

  <?php print $head; ?>

  <title><?php print $head_title; ?></title>

  <?php print $styles; ?>

  <?php print $scripts; ?>

</head>

<body class="<?php print $classes; ?>" <?php print $attributes;?>>

  <div id="skip-link">

    <a href="#main-content" class="element-invisible element-focusable"><?php print t('Skip to main content'); ?></a>

  </div>

  <?php print $page_top; ?>

  <?php print $page; ?>

  <?php print $page_bottom; ?>

</body>

</html>

 

    模板文件,是由两部分组成的,静态的html标记文本,动态的变量。Drupal在生成这个页面时,会把这些变量预先的填充好内容,然后将其套到对应的模板上,这样便合成了一个完整的html页面。对于其它模板来说,是合成了对应功能的html片断。注意这里面的语法:

 

<?php print $page; ?>

 

    这就是一个很普通的php语句,Drupal自带的模板引擎是PHPTemplate,这样只要我们了解一点PHP,便可以很快地上手。对于其它的模板引擎,由于还需要学习额外的语法,学习成本会高那么一点点,所以在Drupal中很少用到。


Drupal版本: