header 中 drupal 模块的位置

position of the drupal module inside the header

我是 Drupal 7 的新手,在这个论坛上,请多多关照:)

我正在尝试自定义一些 drupal 模块 "On the web"(显示 facebook 和 youtube link 按钮)。这个模块很好用,但我想修改这个模块提供的社交图片在 Zen 子主题中的位置。我可以很好地将它放在 left-top 和 header 区域。 正如我在文档中所说:

1)

将以下代码放在您主题的 template.php 文件中,并将 'mytheme' 替换为您的主题名称:

    /**
    * Overrides theme_on_the_web_image().
    */
    function mytheme_on_the_web_image($variables) {
    return $variables['service'];
}

2) 我添加这一行:<div id="myidtomodifythecssafter"> <?php print $service; ?></div> 在 page.tpl.php 中,如下所示:

<?php if ($site_name || $site_slogan): ?>
      <div id="name-and-slogan">
      <div id="myidtomodifythecssafter"> <?php print $service; ?></div>
        <?php if ($site_name): ?>
          <?php if ($title): ?>
            <div id="site-name"><strong>
              <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
            </strong></div>
          <?php else: /* Use h1 when the content title is empty */ ?>
            <h1 id="site-name">
              <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
            </h1>
          <?php endif; ?>
        <?php endif; ?>

        <?php if ($site_slogan): ?>
          <div id="site-slogan"><?php print $site_slogan; ?></div>
        <?php endif; ?>
      </div><!-- /#name-and-slogan -->
    <?php endif; ?>

3) 我清除了缓存

但是模块图像没有出现,我在首页看到这个错误:

Notice: Undefined variable: service in include()

我不明白,我错过了什么?

阅读模块代码后确定: 函数 zhongdao_on_the_web_image 用于主题化锚标记的呈现。这里不是你真正想要的,所以你可以删除它。

此模块创建一个块(在 admin > structure > bloc 下),您可以将其放置在主题区域的任何位置,然后由您使用 CSS 设置不同的样式。 但是如果你想呈现块内容另一个解决方案是这个: https://www.drupal.org/node/26502

Wich 会翻译成这样:

    <?php if ($site_name || $site_slogan): ?>
          <div id="name-and-slogan">
          <div id="myidtomodifythecssafter"> 
<?php 
    $block = module_invoke('on_the_web', 'block_view', 0 /* might want to change depending of your block*/);
    print render($block['content']);
?>
</div>
            <?php if ($site_name): ?>
              <?php if ($title): ?>
                <div id="site-name"><strong>
                  <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
                </strong></div>
              <?php else: /* Use h1 when the content title is empty */ ?>
                <h1 id="site-name">
                  <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
                </h1>
              <?php endif; ?>
            <?php endif; ?>

            <?php if ($site_slogan): ?>
              <div id="site-slogan"><?php print $site_slogan; ?></div>
            <?php endif; ?>
          </div><!-- /#name-and-slogan -->
        <?php endif; ?>