Переопределение функций темы Drupal 7

Я новичок в Drupal, а также в разработке тем Drupal. Узнав, как переопределить шаблон drupal, я захотел узнать, как переопределить функцию темы drupal 7. Из узла Используя слой темы, я узнал следующее:

  1. Для каждой ловушки в модуле нам нужно зарегистрировать функцию ловушки.
  2. Реализация является файлом шаблона, если он определен в возвращаемом массиве функции. В противном случае реализация осуществляется через функцию.

Теперь, следуя книге 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_.


person Nitish    schedule 26.08.2013    source источник


Ответы (1)