原文链接:Theming differences between Drupal 6, 7 & 8
下面是一个 Drupal 8 在主题方面最值得一提的一些变化列表。
- 相比于Drupal 6 和7 的XHTML,Drupal 8 默认输出的是语义化的HTML5标签(请看 Drupal 8 HTML5 Initiative)。
- 除了 jQuery v2.x,Drupal 8 现在引入了更多的前端库,比如Modernizr,Underscore.js 和 Backbone.js。
- Drupal 8 核心 RDFa 模块输出schema.org 标记。
- Drupal 8 改进了无障碍访问(accessibility),通过广泛利用 WAI-ARIA 属性。
- Drupal 8 内置了 Twig,它替代了PHPTemplate作为默认的模板引擎。这意味着函数和基于PHP的文件将会被templates ()所取代。
- Drupal 8 默认开启了性能优化的功能,比如:CSS 和 JavaScript 聚合。
- Drupal 8 在你的管理员界面增加了新的UI元素,引入了模态对话框(modal dialogs)和拖动(drop)按钮。
- Drupal 8 增加了响应式功能,比如:responsive themes,工具栏,图片和表格。
- 在Drupal 6 和 7 里,如果你想添加CSS和JS到一个特殊页面,你可能要分别用 drupal_add_css() 和 drupal_add_js() 函数。现在这个将被替换为insert any JS/CSS assets in the #attached property of a render array。
- Drupal 8 不再支持IE 6,7,8,通过使用 jQuery 2.0 和其他一些代码来增强对现代HTML5/CSS3浏览器的支持。
- Drupal 8 不支持那些不支持 SVG格式的浏览器(包括IE8和安卓浏览器2.3)
- Drupal 8 里的ID比Drupal 7里的CSS要少。
- Drupal 8's CSS (文件) 结构 是基于 SMACSS 和 BEM。
- Drupal 8 的CSS使用了 CSS3 伪元素。
- Drupal 8 增加了 Classy, a core base theme that injects classes into markup, and includes corresponding CSS. 进行中:这将替换以往在核心模块中引入的预处理函数和CSS文件。
- Drupal 8 将预处理函数中添加的class转移到 Twig 模板里。
- Drupal 8 使用 breakpoint media queries 来控制在不同设备上的显示效果。
更多信息
- Upgrading 7.x themes to 8.x
- Change notice for themers
- Sqndr's Drupal 8 theming guide
- Ultimate Guide to Drupal 8: Episode 5 - Front-End Developer Improvements
以下是英文原文,可对照阅读:
Last updated November 30, 2014. Created on October 15, 2014. Edited by brunodbo, mbrett5062, djac, heather. You can edit this page, too.
This is a list of some of the most noteworthy changes in Drupal 8 that affect theming.
- Drupal 8 outputs semantic HTML5 markup by default (see Drupal 8 HTML5 Initiative), compared to XHTML in Drupal 6 and 7.
- Besides jQuery v2.x Drupal 8 now includes more front-end libraries such as Modernizr, Underscore.js and Backbone.js.
- Drupal 8's core RDFa module outputs schema.org markup.
- Drupal 8 has improved accessibility making extensive use of WAI-ARIA attributes.
- Drupal 8 introduces Twig, which replaces PHPTemplate as the default theme engine. This means the
theme_*
functions and PHP-based*.tpl.php
files have been replaced by*.html.twig
templates (). - Drupal 8 enables by default features that improve performance such as CSS and JavaScript aggregation.
- Drupal 8 ships with new UI elements that you use in your own admin screens, including modal dialogs and drop buttons.
- Drupal 8 ships with responsive features such as responsive themes, toolbar, images, and tables.
- In Drupal 6 and 7 if you wanted to add CSS or JS to a particular page, you'd use the drupal_add_css() and drupal_add_js() functions, respectively. This is now replaced by insert any JS/CSS assets in the #attached property of a render array.
- Drupal 8 drops support for IE 6, 7 and 8, enabling the use of jQuery 2.0 and other code that assumes modern HTML5/CSS3 browser support.
- Drupal 8 does not support browsers that do not support SVG (including IE8 and Android Browser 2.3)
- Drupal 8 contains less IDs than Drupal 7's CSS.
- Drupal 8's CSS (file) structure is based on SMACSS & BEM.
- Drupal 8's CSS uses CSS3 pseudo selectors.
- Drupal 8 ships with Classy, a core base theme that injects classes into markup, and includes corresponding CSS. In progress: This will replace many preprocess functions and CSS files which were previously included in core modules.
- Drupal 8 moves CSS classes from preprocess functions to Twig templates.
- Drupal 8 uses breakpoint media queries to control how the site looks on different devices.