drupal节点匹配主菜单链接
下面的代码片断,用来检查当前节点是否匹配一个主菜单链接.这段代码假定主菜单链接的格式为'/somepage'.
下面的代码片断,用来检查当前节点是否匹配一个主菜单链接.这段代码假定主菜单链接的格式为'/somepage'.
这个代码将为你drupal站点上的每个页面的<body>标签生成一个类(class)和id。
在你主题的页面模板文件(page.tpl.php)中,将已存在的<body>标签替换为下面的代码:
<body<?php print phptemplate_body_attributes($is_front, $layout); ?>>
并在你主题的template.php文件中添加下面的代码:
在Drupal 5.0中, PHPTemplate支持在一个主题下,使用多个页面模板.根据当前的url路径(例如node/1, taxonomy/term/2, 或者user/1),PHPTemplate会按照顺序寻找相应的模板,如果找不到的话,将会采用默认的page.tpl.php模板文件。
例如,如果你访问http://www.example.com/node/1/edit,PHPtemplate将按照降序寻找下面的模板:
使用drupal_add_css()函数可以将其它的样式表添加到样式表数组中去:
<?php
// Repeat this line for every CSS file added.
drupal_add_css(path_to_theme() . '/example.css', 'theme', 'all', TRUE);
// Reassemble the $styles snippet to include the new files.
$styles = drupal_get_css();
?>
PHPTemplate在page.tpl.php中提供了一个变量,如果你知道怎么使用的话,它将非常强大.
Drupal 5 ($layout)
$layout包含一个字符串,用来告诉你页面的布局:
如果用的是左栏的话,则为left
如果用的是右栏的话,则为right
如果左右栏都用的话,则为both
默认模板
下面是Drupal 5的bluemarine主题的page.tpl.php模板,让你对页面模板文件有个实际的认识。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language ?>" xml:lang="<?php print $language ?>">
这个模板文件定义了页面的骨架.
可用变量(按字母顺序)
$base_path
返回Drupal安装的URL基路径.最初,这将默认为/。
$breadcrumb
在页面顶部用于展示面包屑的breadcrumb。