HDWiki增加自定义block

2010-09-16 18:05 来源:www.chinab4c.com 作者:admin

       HDWiki自定义block,能让hdwiki有更多,更好的功能发挥。我们将结合一个新的例子.来谈谈如何HDWiki增加自定义block.

      1:

        insert into wiki_block (theme,file,area,areaorder,block,funtpl) values('default','index','bottom',2,'helps','gethelps','gethelps.htm')

      2:新建立block/default/helps目录

      3:新建立block/default/helps/gethelps.htm

     <div id="yqlj" class="columns no_col-h2 bg-gray yqlj i6-ff {$data['config']['style']}" bid="{$bid}">
 <ul class="col-ul list-s">
 <li><span class="bold">热门搜索:</span></li></ul>
 <!--{loop $data['test'] $hotname}-->
 <a href="<!--{if $hotname[url]}-->{$hotname[url]}<!--{else}-->index.php?doc-innerlink-{eval echo urlencode($hotname[name])}<!--{/if}-->" target="_blank">{$hotname[name]}</a>
 <!--{/loop}-->
 
</div>

    4:新建立block/default/helps/helps_inc.htm

   <ul class="col-ul ul_l_s">
    <li><span>选择边框样式:</span>
    <select name="params[style]" >
        <option value="">默认</option>
        <option value="style_01">样式一</option>
        <option value="style_02">样式二</option>
        <option value="style_03">样式三</option>
        <option value="style_04">样式四</option>
        <option value="style_05">样式五</option>
        <option value="style_06">样式六</option>
        <option value="style_07">样式七</option>
        <option value="style_08">样式八</option>
      </select><br />如果默认则不使用额外样式设置。
    </li>
</ul>
    5:新建立block/default/helps/block.php

    <?php
$block['name']='帮助信息';
$block['description'] = '友情链接模块';
$block['author']='互动百科';
$block['version']='4.2';
$block['time']='2010-6-30';
$block['fun'] = array(
 'gethelps'=>'帮助信息'
);
?>

    6:新建立block/default/helps/helps.php

  <?php
class helps{
 var $db;
 function helps(&$base) {
   $this->base = $base;
 }
 function gethelps($setting){
  //return array('cfg'=>$this->base->setting['hotsearch']));
  return array('config'=>$this->base->setting, 'test'=>unserialize($this->base->setting['hotsearch']));
 }
}
?>

   最后更新HDWiki的缓存.完成一个自定义的block

  来源:http:/www.chinab4c.com