宅事

记录闲时弄的小东西

Habari中显示"相关文章"

Habari相关评论的插件,名字叫RN Related Posts,作者是天佑,下载和详细信息看这儿.

使用方法很简单,在需要显示的地方插入这行代码即可:

 <?php echo $related_posts; ?>

这儿写下适合我这个主题的用法,可以作为参考.

我的目标是在sidebar中显示"相关文章",并且只有在显示独立文章页面时sidebar中才出现"相关文章",排版格式符合整体界面.

1)上传related.png小图标到模板的images文件夹.

2)修改插件文件relatedposts.plugin.php的action_add_template_vars函数,改成如下形式:

  1. public function action_add_template_vars( $theme, $handler_vars )
  2. {
  3.     // Get the related posts only if config is setup properly and during
  4.     // 'display_post' action
  5.     if ( !empty( $this->config['num_post'] ) && Controller::get_action() == 'display_post' ) 
  6.        {
  7.         $theme->related_posts= $this->get_related_posts();
  8.         $theme->related_posts= "<h3><img alt=&quot;Related Posts&quot; src=".$theme->
  9. theme_url."/images/related.png />&nbsp;Related Posts</h3>".$theme->related_posts;                      
  10.        }
  11.     else {
  12.          $theme->related_posts= '';
  13.           }
  14. }

3)在CSS中加入:

  1. div#relatedposts ul{
  2.     style-type:none;
  3.     width:100%;
  4.     text-align:right;
  5. }
  6.  
  7. div#relatedposts a:hover {
  8.     border-bottom:2px solid #1ce0e7;
  9. }

4)在sidebar.php中加入:

  1. <!--Related Posts-->                                                           
  2. <div id="relatedposts">                        
  3. <?php echo $related_posts; ?>
  4. </div>

完成了.

 

0 Responses to Habari中显示"相关文章" Article comments Feed

Write a response

Play nice. Be constructive. Allowed HTML tags are: <a>, <strong>, <em> and <blockquote>

« Habari中显示"… 升级habari到0.6.4… »