继续Drupal分享精神 QQ群:107748121 站长QQ:2275288328 skype: hellodrupal【drupal交流+drupal 建站+theme制作】
登录 注册

Drupal theme template.php 简单分析。

如果开发Drupal主题的话,你可能需要使用template.php文件来进行一些重写的操作,在默认主题garland下面就有一个template.php的文件,此文件位于目录themes/garland.看此主题一些函数操作。这个template.php文件不是必须的。在garland主题模板下面的template.php 里面我们可以看到 重写导航面包屑的代码。如下:

<?php
* Return a themed breadcrumb trail.
*
* @
参数 $breadcrumb
包括一个面包屑链接的数组.
* @
返回一个导航面包屑的输出.
*/
function
phptemplate_breadcrumb($breadcrumb) {
  if (!empty(
$breadcrumb)) {
    return
'<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
  }
}
// implode 这是PHP的函数,主要是用用">" 这个符号分割面包屑。你可以用“-”等等,这就是重写了。输出结果可以变为:主页 > 博客 这样的样式.
?>

这个文件作用主要是处理一些主题输出功能。这样完全和表现层分开,控制显示内容输出。

评论

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 自动断行和分段。
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.