Search code examples
cssmoduledrupal-7position

position of the drupal module inside the header


i m new to Drupal 7 and in this forum, please be nice :)

I m trying to customize a bit the drupal module "On the web" (that display facebook and youtube link button). This module work great but I would like to to modify the position of the social images provided by this module inside a sub theme of Zen. I could be nice to put it at the left-top the header region. As it says in the documentation I :

1)

Place the following code in the template.php file in your theme, and replace 'mytheme' with the name of your theme:

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

2) I add this line : <div id="myidtomodifythecssafter"> <?php print $service; ?></div> in the page.tpl.php like following :

<?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) I cleared the cache

but then the module images don't appear and i got this error in the front page :

Notice: Undefined variable: service in include()

i don't understand, what did I miss ?


Solution

  • Ok after reading the module code : The function zhongdao_on_the_web_image is for theming the rendering of your anchor tags. Not really what you want here, so you can remove it.

    This module create a block (under admin > structure > bloc) that you can position anywhere in your theme regions, then up to you to style it differently with CSS. But if you want to render the block content another solution is this one : https://www.drupal.org/node/26502

    Wich will translate to something like this :

        <?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; ?>