我的想法是,在首頁上不同的區域分別呈現不同類別的文章,
所以我在main.template檔上,插入這樣的程式碼
<div id="content">
{assign var=postCategory value=$post->getCategory()}
{assign var="postDate" value=$post->getDateObject()}
{assign var="postOwner" value=$post->getUserInfo()}
{assign var=stickys value=$stickyposts->getArticles(29)}
{assign var=stickyCategory value=$stickyposts->getCategory(29)}
<h2>Sticky Posts</h2>
{foreach from=$stickys item=post}
<table border="0" width="400" id="table4" cellspacing="0" cellpadding="0">
<tr>
<td width="20"><img src="{$url->getTemplateFile("images/titlelist.gif")}"</td>
<td width="180"><a href="{$url->postPermalink($post)}"><font size="2">{$post->getTopic()}</font></td>
<td width="80" align="left">
<a href="{$url->categoryLink($postCategory)}"><font size="2">| {$postCategory->getName()}</font></a></td>
<td width="60" align="center">
<img alt="迴響" src="{$url->getTemplateFile("bubble.gif")}" width="11" height="11" style="border: 0px" align="absbottom" /> <a href="{$url->postPermalink($post)}"><font size="2">| ({$post->getTotalComments()})</font></a></td>
<td width="60" align="center">
<img alt="引用" src="{$url->getTemplateFile("trackback.gif")}" width="16" height="11" style="border: 0px" /> <a href="{$url->postTrackbackStatsLink($post)}"><font size="2">| ({$post->getNumTrackbacks()})</font></a></td>
</tr>
</table>
{/foreach}
<h4><a href="{$url->categoryLink($stickyCategory)}">more sticky posts</a></h4>
</div>
其中getArticles(29),是我的文章分類的代號,
但是會有以下的錯誤的訊息,
Fatal error: Call to a member function on a non-object in /var/www/html/ilan/tmp/21/%%737^%%737864322^main.template.php on line 71
但是很神奇的,
我如果把上面的程式碼放在一個檔案中,如title29.template
然後在main.template改為,
{foreach from=$posts item=post}
{include file="blueish/title29.template"}
{/foreach}
就可以將文章列出來耶
如圖
當然,這還不是我要的結果,
而且它會一直重複10次列出分類文章!
還不曉得是什麼原因說...[/quote]