Drupal文档翻译 - 怎样升级改写6.x主题至7.x适用(1) 概述

logo-drupal-documentation本站原创编译,转载请给面子,尊重劳动果实,欢迎交流指正。

又是持续晴好的艳阳天,风再小些就完美了。话说不把做内容当做日常任务而只是随意搞搞的感觉蛮好,当然还是需要有时间和心情。不再像去年那样一早坐下磨一大杯咖啡然后争取在10点前赶出一篇什么东西,仿佛强迫症;咖啡也戒掉了一个多月的样子。不敢说乐活,就是少跟自己过不去。

说正事;找了几篇文档,最后觉得还是这篇最想做掉:Converting 6.x themes to 7.x,属于官方文档中“升级主题至新版本”的话题;另外一篇讲5.x升级至6.x的就不说了。记得在其他地方读到过这篇的译文;找不到也懒得找,随自己开心翻一遍,当做学习。之前写的Drupal 7主题也多少让自己有了些直观的认知,可惜这次做的东西出于性能、兼容性等方面的考虑最终还是使用了D6。

目前的原文更新于3月27日,通过53个要点,陈述了Drupal 7在主题模板方面的新功能及变化。今天这篇概述中先将这些要点及原文链接列在这里;其中[U]为最后更新版本的单篇链接:

  1. 区块有新的含义更加准确的id命名 -  [U] Blocks have new, more meaningful CSS IDs
  2. 主菜单和次级菜单的命名变为Main menu和Secondary menu - [U] Primary and secondary links are now Main and Secondary menu
  3. node.tpl.php文件无法再通过$taxonomy变量输出未被渲染的词汇表链接条目 - [U] Unrendered taxonomy links are no longer available as a separate variable in node.tpl.php files
  4. html.tpl.php文件在头部为RDFa进行必要的改动 - [U] RDFa requires some changes at the beginning of html.tpl.php
  5. 原来的class名“clear-block”被重新命名为“clearfix” - [U] The clear-block class has been renamed to clearfix
  6. 移除了box.tpl.php模板文件 - [U] The box.tpl.php template has been removed
  7. 添加了$help区域 - $help became a region
  8. 取消了Mission statement的概念,代之以新的“高亮”区域(highlighted) - [U] Mission statement removed, 'highlighted' region suggested
  9. 移除了用于输出页脚信息的变量$footer_message - [U] Footer message removed
  10. $content区域不可移除,页面的主要内容部分变为一个区块 - [U] Content region is now mandatory, main page content became a block
  11. 添加了一个新的预处理函数阶段 - [U] Second phase variable process functions
  12. 可以在模板文件中使用一个变量生成class - HTML classes generated through a variable
  13. 可以在模板文件中使用一个变量生成HTML标签属性 - HTML attributes generated through a variable
  14. 变量预处理函数可以用于所有theming hooks - Variable process functions can now be used for all theming hooks
  15. 所有的主题函数都可以接受统一的$variables参数 - All theme functions now take a single argument, $variables
  16. 函数名必须与主题名称匹配 - [U] Function names must match theme name
  17. 所有CSS与JavaScript文件必须在主题的.info文件中声明 - [U] All CSS and JavaScript files must be specified in the theme's .info file
  18. 在block.tpl.php文件中重新命名了$block->content变量 - Renamed $block->content in block.tpl.php
  19. 节点与用户模板中的颗粒化渲染 - Granular rendering in node and user templates
  20. jQuery UI(1.8)被整合进系统 - [U] Added jQuery UI (1.8) to core
  21. 可以为独立元素定义调用JS与CSS文件 - Attached JS/CSS for elements
  22. 新的$page_bottom区域替代了以前的$closure变量输出;另外新增$page_top和$hidden区域 - $closure becomes $page_bottom, new $page_top and hidden regions
  23. $left、$right被重新命名为“$sidebar_first”和“$sidebar_right”$left and $right variables are now $sidebar_first and $sidebar_second; CSS IDs also changed
  24. $picture被重新命名为$user_picture,相应的class由“picture”变为“user-picture”$picture changes to $user_picture, and the CSS class 'picture' to 'user-picture'
  25. 新增了两个class,用于在不同情况下隐藏内容 - New classes available to hide content in an accessible manner
  26. JS变量Drupal.jsEnabled被移除 - JavaScript variable Drupal.jsEnabled has been removed
  27. PHPTemplate引擎的模板建议通配符 - PHPTemplate suggestion wildcard
  28. 在system_elements()函数中需要明确包含主题定义 - Include theme definition explicitly on element when using system_elements()
  29. 在安装过程中添加了当前任务的标示,在禁用CSS或使用屏幕阅读器的情况下保证可读 - Added markup to make installation task progress perceivable with screen-reader and CSS disabled.
  30. 为theme_breadcrumb()添加了隐藏的用于表示“当前”的隐藏标示,对屏幕阅读器更友好 - Added an invisible heading to theme_breadcrumb().
  31. 修改了RSS图标的alt和标题文案 - Changes to alt and title attribute for the RSS feed icon
  32. 将搜索模块从主题层移至模块 - Search box moved from theme layer to blocks
  33. 修改了菜单的树形结构、链接及tab切换的函数渲染方式 - Changes to menu tree, link and tab rendering functions
  34. 为theme_links()函数添加了新的$heading参数,提高可访问性 - theme_links() has a new parameter $heading for accessibility
  35. 移除了theme_get_setting()和THEME_settings()函数 - theme_get_setting() and THEME_settings() have been improved
  36. 添加了theme_form_required_marker()函数 - Added a theme_form_required_marker() function
  37. 添加了theme_link()函数 - Added a theme_link() function
  38. 在系统主题中添加了“跳至主要内容”的链接 - Skip to main content links in core themes
  39. 可以在主题中使用那些用于在内容加载之前显示备用内容的hook - Alter hooks available to themes
  40. 系统模块的样式表被重新组织整理,将行为与表现方面的样式分离 - System module stylesheets have been reorganized to separate behavior-supporting styles from presentational styles
  41. 添加了用于添加快捷方式的主题设置 - New theme setting for displaying the Shortcut module "add to shortcuts" link
  42. 覆写模板文件时,文件名连缀符由“-”变为“--” - Specific template overrides of generic templates use a '--' delimiter instead of '-'
  43. 不同情况下分别使用@import或link的方式调用CSS文件 - CSS files are sometimes loaded with @import, sometimes with LINK tags
  44. 针对特殊浏览器环境进行的CSS文件调用可以并且应该试用drupal_add_css()方法 - [U] Browser-targeted CSS files can and should be added using drupal_add_css()
  45. Targeted overrides (suggestions) available for theme_menu_link() and theme_menu_tree()
  46. theme_submenu()被移除 - theme_submenu() was removed
  47. 模板中添加了新的$title_prefix和$title_suffix标题前后缀变量 - New $title_prefix and $title_suffix template variables
  48. 移除了theme_node_form()函数 - theme_node_form() was removed
  49. node_get_types()被重新命名为node_type_get_types() - node_get_types() renamed to node_type_get_types()
  50. 系统自带主题的.info文件中包含了“package=Core”的信息 - Core themes now contain "package = Core" in their .info files
  51. search-result.tpl.php文件中添加了更符合语义的标题元素 - Heading elements added to search-result.tpl.php
  52. <a>与<map>标签中禁用name属性 - The name attribute in a and map elements is invalid
  53. PHPTemplate引擎成为默认的主题模板引擎 - PHPTemplate is now the default theme engine

译者:Viiiix7210

如需转载,请注明官方英文文档及本人译文的出处,谢谢。查看英文原文: Converting 6.x themes to 7.x


收藏与分享