在zblogphp主题功能设计中,有些模块需要调用站长指定的文章,例如:CMS主题,主题侧栏模块,推荐文章模块等,主题配置中通常的做法是设置需要显示的文章id号,多个用英文小逗号隔开,这种方法虽然能达到效果,但是操作起来还是不够能活,需要去查询文章ID号。所以今天写了另一种方法,大家觉得合适可以拿去试试。
Add_Filter_Plugin('Filter_Plugin_Edit_Response5','umWm_postType');
2,在include.php加入接口配置字段
function umWm_postType() { global $zbp, $article; if($article->Type=="0"){ $postType='加入首推|加入精选'; $array=explode('|',$postType); foreach ($array as $v) { echo ' <input type="hidden" name="meta_'.$v.'" value=""/> <label> <input type="checkbox"name="meta_'.$v.'" value="'.htmlspecialchars($v).'" '; if ($article->Metas->$v == $v){echo 'checked="checked"';} echo ' class="'.$v.'" /> '.$v.'</label><br />'; } } }
3,在include.php加入调用代码
加入首推调用函数
function umWm_stHtml() { global $zbp; $umOrder = array('log_PostTime'=>'DESC'); $umWhere = array(array('=','log_Status','0')); $umWhere[]=array('like','log_Meta','%加入首推%'); $umArray = $zbp->GetArticleList(array('*'),$umWhere,$umOrder,array(10),''); foreach ($umArray as $umlist) { echo '<li><span>'.$umlist->Time('Y-m-d').'</span><a href="'.$umlist->Url.'">'.$umlist->Title.'</a></li>'; } }
加入精选调用函数