下方分享的代码是昨天定制模板过程中需要的代码,功能为:zblog模板首页调用多分类模块,同时可以调用分类编辑内指定推荐文章ID,如果不在分类内推荐则调取分类内最新文章,同时可以分类编辑内设置调取最新的数量。
{php}$ydtao_cateids = explode(',',$zbp->Config('ydtao')->ydtao_cateid);{/php} {foreach $ydtao_cateids as $key=>$id} {if isset($categorys[$id])} <div class="sticky"> <h2 class="title">{$categorys[$id].Name}</h2> <ul> {if $categorys[$id]->Metas->tjid}//分类内推荐字段来判断 {php} $tjids = $categorys[$id]->Metas->tjid; $array = explode(',',$tjids); {/php} {foreach $array as $key=>$id} {$post=GetPost((int)$id);} <li class="item"> <a href="{$post.Metas.url}" target="_blank"> <span>{$post.Title}</span> <div class="taoimg"><img alt="{$post.Title}" title="{$post.Title} " src="{ydtao_thumbnail($post)}" width="80" height="80"></div> <p>掌柜:{$post.Metas.zhanggui}</p> <p>信用:<img src="{template:post-xinyong-post}" alt="" /></p> <p>行业:{$post.Metas.hangye}</p> </a> </li> {/foreach} {else} {php} if($categorys[$id]->Metas->tjshu) $tjshus = $categorys[$id]->Metas->tjshu; else $tjshus = 20; {/php} {foreach GetList($tjshus,$id,null,null,null,null,array('has_subcate'=>'ture')) as $key=>$post} <li class="item"> <a href="{$post.Metas.url}" target="_blank"> <span>{$post.Title}</span> <div class="taoimg"><img alt="{$post.Title}" title="{$post.Title} " src="{ydtao_thumbnail($post)}" width="80" height="80"></div> <p>掌柜:{$post.Metas.zhanggui}</p> <p>信用:<img src="{template:post-xinyong-post}" alt="" /></p> <p>地址:{$post.Metas.hangye}</p> </a> </li> {/foreach} {/if} </ul> </div> {/if} {/foreach}