HDwiki精彩词条按人气排序

2010-09-25 15:42 来源:www.chinab4c.com 作者:admin

    HDwiki精彩词条按人气排序,目前HDwiki的精彩词条是按照推荐来显示的。为了方便使用和让HDwiki变的更人性化.我们可以通过对HDwiki二次开发。达到HDwiki按照人气排行来显示.我们必须对HDwiki的block进行调整

    1:block/default/doc/doc.php

     function wonderdocs($setting){
  $this->base->load('doc');
  $num=$setting['num']?$setting['num']:$this->base->setting['index_wonderdoc'];
  $type = 3;
  $list = $_ENV["doc"]->get_by_votes(0,$num);
  
  if(count($list)>0){
   $fistwonderdoc=is_array($list)?array_shift($list):array();
   $fistwonderdoc['image'] = str_replace('s_','',$fistwonderdoc['image']);
  }
  
  return array('config'=>$setting, 'list'=>$list, 'fistwonderdoc'=>$fistwonderdoc);
 }

    2:model/doc.class.php

     function get_by_votes($start = 0 ,$limit = 10){
  $sql = "select * FROM ".DB_TABLEPRE."doc d where visible = 1 order by votes desc LIMIT $start,$limit";
  
  $query = $this->db->query($sql);
  while($doc=$this->db->fetch_array($query)){
   
   $doc['iscreate']=($doc['time']==$doc['lastedit']);
   $doc['lastedit']=$this->base->date($doc['lastedit']);
   $doc['time']=$this->base->date($doc['time']);
   $doc['rawtitle']=$doc['title'];
   
   $doc['title']=htmlspecialchars($doc['title']);
   $doc['shorttitle']=(string::hstrlen($doc['title'])>16)?string::substring($doc['title'],0,16)."...":$doc['title'];
   $doc['category']=$categorylist[$doc['cid']];
   $doclist[]=$doc;
  }
  return $doclist;
 }

  3:block/default/doc/wonderdoc.htm修改成以下代码

   <div id="jcct" class="columns jcct {$data['config']['style']}" bid="{$bid}">
<h2 class="col-h2">{lang wonderDoc}</h2>
<a href="{url list-focus-3}"  class="more">{lang more}</a>

    <ul class="col-ul point font-14 link_blue ">
        <!--{loop $data['list'] $wondoc}-->
            <li><a href="{url doc-view-$wondoc['did']}" >{$wondoc['title']}</a>: {$wondoc['summary']}</li>
        <!--{/loop}-->
    </ul>

</div>

   来源:http://www.chinab4c.com