下方分享的代碼是昨天定制模板過程中需要的代碼,功能為: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}