Drupal手册

Drupal手册

主题化Web-Form

This is one of the finest technique I found so far to theme webform form. In fact, it could be used for any form generated through Drupal FORM API.

For Example, I needed certain elements of the form to be on one line (horizontally placed), I could do something like below. This is just override function of "template_preprocess_webform_form" provided by webform module. Place this in your theme's template.php file.

清除主题的缓存

The contents of the .info file is cached in the database, so altering it will not be noticed by Drupal. Do not confuse the cache with the theme registry. To clear the cache, do one of the following:

整合color 模块

Color.module allows the admin to change the color scheme of a theme completely. By selecting a palette of 5 colors (either from a set or by hand), you can change the colors of an entire theme.

The module can alter the stylesheet and re-render images. However, the theme must provide specific hooks to allow this, and the design must be created specifically to accomodate this.

This document explains the basics of making a colorizable theme.

全局设置

在后台的主题管理中(Administer > Site building > Themes)点击“Configure”进入全局设置页面。在这里我们可以对主题做一系列的设置,包括昨天提到的页面元素的显示状态等。在这个页面中,我们还可以进入已启用主题的设置页面,对这些主题进行单独设置;它们会覆盖掉全局设置。

我们把一些常规的页面元素设置项列在下面,加以解释;需要注意的是,并非所有的主题都支持所有这些元素,正像我们在前一篇中讲到的。

主题设置

很多由主题输出的页面元素都可以在主题管理中设置显示状态(显示或隐藏)。进入当前主题的设置页面(Administer > Site building > Themes > 主题名称),我们可以看到类似下面截图所示的设置项目:

drupal-theme-features-enabled

我们可以通过勾选或取消勾选页面元素前面的checkbox来设定该元素是否显示。

我们可以通过.info文件中features键值的声明来控制究竟哪些元素可以被这样设置;如果没有做声明,那么系统默认会启用下面这些元素:

检查一个区域是否被占用

While theming page.tpl.php it's possible to check to see whether a region is empty, by checking the content of the relevant variable which contains the region's contents.

For example;
Drupal 6

<?php
 
if($left) {
   
// do something
 
}
?>

Drupal 7

 
<?php
 
if($page['sidebar_first']) {
   
// do something
 
}
?>

向区域分配内容

概念上,它是主题中的一些容器我们可以向里面添加区块(blocks)和内容。区域是在.info 文件中通过“regions”键值声明定义的,我们在前面一档中也有讲到过。“regions”键值使用如下的形式:

regions[theRegion] = The region label

方括号中的键使用机器可读名称,右侧对应值为用户可读名称。如果未作声明,系统默认会在主题中定义以下几个区域:

默认的.info 信息

The following are the assumed defaults. When they are not defined, the theme will automatically take these values.

Note: These defaults apply as a group. In other words, overriding a region with regions[sub_header] = Sub-header will omit the rest of the default regions. To gain them back, they must be redefined. This also applies to stylesheets. Even though it's not technically in a group, defining another stylesheet will prevent "style.css" from being included unless it is redefined.

regions

Drupal 6

6. 内容类型page 和story的区别

分别创建一个Page节点,和一个Story节点,并比较它们之间的区别。

答案:

Page和Story节点类型,是Drupal自带的两种节点类型,在drupal7中,story被更名为了Article。

Page主要应用于静态的页面,而Story则应用于动态性的文章,比如部门的新闻,对于个人博客网站,如果是单人博客的话,一般用Story作为博客。Page没有节点的发布信息,而Story有。

Page默认是不会被推到首页的,而Story默认被推到首页。Page默认是禁止评论的,而Story则允许评论。从这几点可以看出,Story更具有交互性。

5. 如何配置drupal 的简洁链接

示例:drupalgarden.cn/?q=user ,drupalgarden.cn/user,后者就是简洁URL,去掉了“?q=”的URL。简洁URL的好处,SEO。

这里以XAMPP集成安装包为例,介绍如何配置简洁链接:

1、 F:\xampp\apache\conf,在该目录下找到httpd.conf文件,打开,找到#LoadModule rewrite_module modules/mod_rewrite.so。

将前面的注释符“#”去掉。

2、把F:\xampp\apache\conf\apache conf里面的AllowOverride None改为了AllowOverride All,试了一下

同步内容