【问题标题】:position of the drupal module inside the header标头内drupal模块的位置
【发布时间】:2016-01-06 08:20:41
【问题描述】:

我是 Drupal 7 的新手,在这个论坛上,请善待 :)

我正在尝试自定义一些“在网络上”的 drupal 模块(显示 facebook 和 youtube 链接按钮)。这个模块很好用,但我想修改这个模块提供的社交图像在 Zen 的子主题中的位置。我可以把它放在标题区域的左上角。 正如它在文档中所说的那样:

1)

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

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

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

<?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) 我清除了缓存

然后模块图像没有出现,我在首页收到此错误:

注意:未定义变量:include() 中的服务

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

【问题讨论】:

  • 在 template.php 中,您是否在 theme_hook 函数中将 mytheme 替换为您的主题名称,因为您显示的代码没有?并且错误消息指向这个想法,即变量未定义,即您的主题看不到您的 theme_on_the_web_image 函数。
  • 嗨 Laurent,是的,我做到了:所以现在是 -> function zhongdao_on_the_web_image($variables) {

标签: css module drupal-7 position


【解决方案1】:

阅读模块代码后确定: 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; ?>

【讨论】:

  • 完美答案,谢谢洛朗!它的工作和内容确实出现了。我想我还有很多工作要掌握 Drupal。顺便说一句,你能给我推荐一本关于这方面的好书吗(en français si possible)?
  • 没问题。我主要使用 drupal.org 和 forums/blog,所以抱歉,我不会成为最好的书籍建议。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-12-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多