You are here

Static page模块

g089h515r806 的头像
Submitted by g089h515r806 on 星期五, 2013-07-12 04:21

昨天,在帮助外研社解决Drupal技术问题的时候,遇到这样的问题,有几个专题页面,静态页面已经做好了,想放到Drupal里面来,这几个专题页面,和Drupal的主题系统没有任何关系。

通常的做法是这样的,把这些专题页面的主内容放到节点里面,然后覆写这些节点的输出,不显示任何的Drupal多余区块、区域,只显示节点的内容。我感觉这种方式比较麻烦,找了一下,也没有找到一个模块,用来解决这个问题。官方所给的解决办法就是,我上面所说的,不走Drupal的流程,为什么还要使用Drupal啊。

不过一个页面。,总有那么几个专题页面,是这样的。所以我权衡了一下,决定自己写一个模块,来绕过Drupal的主题层直接把存储的页面显示出来。这就是Static page模块。模块比较小,用法也很简单:

  1. 安装Static page模块。
  2. 导航到“admin/config/content/static_page”,这里面选择哪个内容类型用作Static page,注意,尽管这里是多选,通常选择一个就可以了。对于选中的内容类型,需要保留它的body字段。我们模块里面就是使用的这个字段存储整个HTML页面的源代码的。
  3. 进入node/add页面,这里选择步骤2里面选中的内容类型,添加静态页面。输入标题,注意在body里面,输入整个HTML页面的源代码。

保存即可,这样你就可以看到和设计一模一样的静态页面了,当然,需要调整一下路径问题。

模块简单易用,代码量也很简洁。

How to use:

1, Install static_page module

2,Navigate to “admin/config/content/static_page”, Here choose which content type will be used as static page. You could add a dedicated content type, for example “Static page”, then use it. Make sure that your content type has a body field. This module use body field to store the whole source code of a HTML page.

3,Navigate to “node/add” page, choose the content type tha tselected on step 2,  for example “node/add/ static_page”. Here you enter a title, then put the whole source code of a HTML page into drupal’s body field. Save it.

 

You will get a page exactly the same with your source code. This module help you bypass Drupal’s theme layer.

 

Drupal版本:

评论