2013-08-26 130 views
0

我是Drupal以及Drupal主题开发的新手。学习如何重写drupal模板后,我想知道如何重写drupal 7主题函数。从节点Using the theme layer,下面的事情我已经学会:覆盖Drupal 7主题功能

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

现在下面的书A definative guide to Drupal 7,重写一个主题功能 1.复制 - 主题功能粘贴到我的主题的template.php文件中 2.更改文件名开头的从theme_yourtheme_ 3.保存 为了让例子,它覆盖了以下功能:

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

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_开始的。

回答

1

核心评论模块更新为hook_help函数。您必须在自定义模块中使用相同的功能。请注意,您应该先使用$output = "";

+0

@Nitish清理任何$输出数据此答案是否解决了您的问题?如果是这样,请给出一些反馈(upvote,选择为可接受的)。 – TheodorosPloumis