【问题标题】:Making new variable for drupal 7 theme showing error notice为显示错误通知的 drupal 7 主题制作新变量
【发布时间】:2013-07-14 05:19:08
【问题描述】:

您好,我正在尝试为 drupal 7 主题创建一个新变量。我的主题名称是ntheme。为此,我在template.php 中定义了一个函数:

function ntheme_gnu_preprocess(&$variables)
{
    $variables['disclaimer'] = t('Comments are unaythorized. The views expressed are those of the comment author.');
}

并在comment-wrapper.tpl.php中使用了这个变量$disclaimer

<div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if ($content['comments'] && $node->type != 'forum'): ?>
    <?php print render($title_prefix); ?>
    <h2 class="title"><?php print t('Comments'); ?></h2>
    <?php print render($title_suffix); ?>
  <?php endif; ?>

  <?php print render($content['comments']); ?>

  <?php if ($content['comment_form']): ?>
    <h2 class="title comment-form"><?php print t('Add new comment'); ?></h2>
    <?php print render($content['comment_form']); ?>
  <?php endif; ?>
  <p><?php print $disclaimer; ?></p>
</div>

但它显示通知:

注意:未定义的变量:include() 中的免责声明(第 39 行) C:\wamp\www\drupal\sites\all\themes\ntheme\templates\comment-wrapper.tpl.php)。

我做错了什么?

【问题讨论】:

    标签: variables drupal drupal-7 drupal-themes


    【解决方案1】:

    您的主题名称是 ntheme_gnu 还是 ntheme,因为如果您的主题名称是 ntheme,您应该将 hook_preprocess 称为 ntheme_preprocess()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-27
      • 2019-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多