<< pLog 迴響模版的迴響編號 | Plog.HomePage | pLog 的簡潔網址 >>
pLog recentcomment plugin 中,利用 smarty 的判斷,設定時間或日期
{assign var=comments value=$recentcomments->getRecentComments(15)}
{foreach from=$comments item=comment}
{assign var=commentDate value=$comment->getDateObject()}
{if $locale->formatDate($commentDate,"%D") eq $locale->formatDate($now,"%D")}
{else}
{$locale->formatDate($commentDate, "%m/%d")}
{/if}
此方法為懶人法,首先請參考 修改方法一 找到 recentcomment 插入的位置,然後將 recentcomment 整個置換成下列程式碼。
{assign var=comments value=$recentcomments->getRecentComments(15)}
{foreach from=$comments item=comment}
{assign var=postid value=$comment->getArticleId()}
{assign var=commentDate value=$comment->getDateObject()}
{assign var=post value=$recentcomments->getCommentArticle($postid)}
{if $comment->getUserUrl()}
<li><a title="{$comment->getText()|truncate:150:"..."|escape}"
href="{$url->postPermalink($post)}#{$comment->getId()}">
{$post->getTopic()}</a><div align="right">
<font style="font-size: 11px;">{$comment->getUsername()} @
{if $locale->formatDate($commentDate,"%D") eq $locale->formatDate($now,"%D")}
{$locale->formatDate($commentDate, "M")}
{else}
{$locale->formatDate($commentDate, "%m/%d")}
{/if}
</font></div></li>
{else}
<li><a title="{$comment->getText()|truncate:150:"..."|escape}"
href="{$url->postPermalink($post)}#{$comment->getId()}">
{$post->getTopic()}</a>
<div align="right">
<font style="font-size: 11px;">{$comment->getUsername()} @
{if $locale->formatDate($commentDate,"%D") eq $locale->formatDate($now,"%D")}
{$locale->formatDate($commentDate, "M")}
{else}
{$locale->formatDate($commentDate, "%m/%d")}
{/if}
</a></font></div></li>
{/if}
{/foreach}
<< pLog 迴響模版的迴響編號 | Plog.HomePage | pLog 的簡潔網址 >>