开发者

Rearrange ordering of blog posts vs content block?

Right now, I have blog posts being generated as nodes in my main content area. In my content block there's only one block and that's for the blog navigation which needs to be on 开发者_开发技巧top of the blog posts and it has very custom markup - how could I reverse the order? I'm not sure where to move the posts down.

Clarification: I need my block to show up on the homepage only, where the blog posts are and I need it to show above the blog posts.


Unfortunately, there isn't an easy way of accomplishing this through the graphical administrative interface, so you'll probably have to get into your theme code to make this change. IMO, the easiest way to do this is to define a new block region.

If you're using a contributed/core theme, you might want to define a sub-theme of your current theme to make the change in. See http://drupal.org/node/225125 for more information about subthemes.

To create a new block region, you need to add it to your theme's .info file


name = My Theme
description = Example
core = 6.x
engine = phptemplate

regions[left] = Left Sidebar
regions[right] = Right Sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
regions[above_content] = Above content

Here, in addition to the default regions (left, right, content, header, footer), the theme has a custom region called above_content.

Then, edit your theme's page.tpl.php file, and add the $above_content variable to the template where it will display above the content. For example, if you were extending the Garland theme, you could add the $above_content variable like so:

...
<div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
          <?php print $breadcrumb; ?>
          <?php if ($mission): print '<div id="mission">'. $mission .'</div>'; endif; ?>
          <?php if ($tabs): print '<div id="tabs-wrapper" class="clear-block">'; endif; ?>
          <?php if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif; ?>
          <?php if ($tabs): print '<ul class="tabs primary">'. $tabs .'</ul></div>'; endif; ?>
          <?php if ($tabs2): print '<ul class="tabs secondary">'. $tabs2 .'</ul>'; endif; ?>
          <?php if ($show_messages && $messages): print $messages; endif; ?>
          <?php print $help; ?>
          <div class="clear-block">
            <?php print $above_content ?>
            <?php print $content ?>
          </div>
          <?php print $feed_icons ?>
          <div id="footer"><?php print $footer_message . $footer ?></div>
      </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->
...

You can then add the block to the 'Above content' region on the block admin page and set it to only display on the front page.


You can control the visibility of blocks in it's settings in three ways:

  • PHP statement
  • On all pages except listed
  • Only on listed pages
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜