置頂文章公告 plugins stickyposts
增加置頂文章公告的外掛,我所用的是 stickyposts 1.2 的版本,依照 readme 的說明,先在文章分類新增一個置頂文章公告的分類,在個人網誌設定=>網誌最近活動管理=>置頂及公告文章設定 中啟動外掛及設定置頂文章分類,然後在樣本中的 main.template 中加入紅色部份
{if $category}<h2>{$locale->tr("category")}: {$category->getName()}</h2>{/if}
{if empty($showAll) && $stickyposts->isEnabled()}
{assign var=stickys value=$stickyposts->getArticles('sticky')}
{if $stickys|@count > 0}
<div class="post">
<h2>置頂文章</h2>
<div class="posthead">
{foreach from=$stickys item=post}
<a href="{$url->postPermalink($post)}">{$post->getTopic()}</a>
{/foreach}
</div>
</div>
{/if}
{/if}
{foreach from=$posts item=post}
我的加法是配合樣本格式,及判斷如果沒有置頂公告文章就不顯示區塊,與 readme 有一點不一樣,因為我覺得這個功能對我個人來說不太可能用到,如果沒有置頂文章,卻佔用一個空block區塊,感覺上很奇怪,所以加入,如果沒有置頂文章就不顯示的判斷