首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >覆盖Drupal 7主题函数

覆盖Drupal 7主题函数
EN

Stack Overflow用户
提问于 2013-08-26 09:30:09
回答 1查看 895关注 0票数 0

我是Drupal和Drupal主题开发的新手。在学习了如何覆盖drupal模板之后,我想知道如何覆盖drupal 7主题函数。从节点使用主题层中,我学到了以下内容:

  1. 对于模块中的每个钩子,我们需要注册一个钩子函数。
  2. 如果是在函数的返回数组中定义的,它就是“模板”文件。其他方法的实现是通过功能实现的。

现在,按照“A definative guide to Drupal 7”一书,重写主题函数1。将主题函数复制粘贴到主题的template.php文件2。将文件名的开头从theme_更改为yourtheme_ 3。保存到示例,它将重写以下函数:

代码语言:javascript
复制
function theme_more_link($variables) {
  return '<div class="more-link">' . l(t('More'), $variables['url'], array('attributes' => array('title' => $variables['title']))) . '</div>';
}

现在,如果我想重写主题函数comment_help()中的comment.module

代码语言:javascript
复制
function comment_help($path, $arg) {
  switch ($path) {
    case 'admin/help#comment':
      $output = '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Comment module allows users to comment on site content, set commenting defaults and permissions, and moderate comments. For more information, see the online handbook entry for <a href="@comment">Comment module</a>.', array('@comment' => 'http://drupal.org/documentation/modules/comment/')) . '</p>';
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Default and custom settings') . '</dt>';
      $output .= '<dd>' . t("Each <a href='@content-type'>content type</a> can have its own default comment settings configured as: <em>Open</em> to allow new comments, <em>Hidden</em> to hide existing comments and prevent new comments, or <em>Closed</em> to view existing comments, but prevent new comments. These defaults will apply to all new content created (changes to the settings on existing content must be done manually). Other comment settings can also be customized per content type, and can be overridden for any given item of content. When a comment has no replies, it remains editable by its author, as long as the author has a user account and is logged in.", array('@content-type' => url('admin/structure/types'))) . '</dd>';
      $output .= '<dt>' . t('Comment approval') . '</dt>';
      $output .= '<dd>' . t("Comments from users who have the <em>Skip comment approval</em> permission are published immediately. All other comments are placed in the <a href='@comment-approval'>Unapproved comments</a> queue, until a user who has permission to <em>Administer comments</em> publishes or deletes them. Published comments can be bulk managed on the <a href='@admin-comment'>Published comments</a> administration page.", array('@comment-approval' => url('admin/content/comment/approval'), '@admin-comment' => url('admin/content/comment'))) . '</dd>';
      $output .= '</dl>';
      return $output;
  }
}

我该怎么做呢?它的名称不是从theme_开始。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-26 20:03:15

核心注释模块是提高帮助功能。您必须在自定义模块中使用相同的函数。请注意,您应该首先使用$output清除任何$output = "";数据。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18440935

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档