给zblogphp博主评论增加admin印章的方法
372
16
上午折腾了在评论中让博主的留言显示别名,但还是觉得有些不满意,于是想把博主的留言加上印章。
百度搜索了很多方法,都是wordpress的方法,好在思路都一样,那就自己动手吧。
1、要分出博主和留言者,这样才行,上篇文章已经解决了,这里就不赘述了。
2、显示印章,如图所示,我想要的结果。
3、实现方法,该方法其实只用到css加一个div层就能实现,先在网上找到一个admin印章图片,放到模板的style\img目录(也可能是images)下,在style目录下的css文件最下面加上如下代码
<div class="dp-highlighter">
<div class="bar"></div>
<ol class="dp-c" start="1">
<li class="alt">.admincomment{</li>
<li class="">background:url(img/admin.gif) 120px 0 no-repeat;<span class="comment">/*120PX 意思是距左侧距离*/</span></li>
<li class="alt">position:relative; <span class="comment">/*找这个花了2个小时,意思是放在最顶端*/</span></li>
<li class="">}</li>
</ol>
</div>
<div class="dp-highlighter">
<div class="bar"></div>
<ol class="dp-c" start="1">
<li class="alt">{<span class="keyword">if</span> <span class="vars">$comment</span>.Author.Email==<span class="vars">$article</span>.Author.Email}</li>
<li class=""><div <span class="keyword">class</span>=<span class="string">"admincomment"</span>></li>
<li class="alt"><span <span class="keyword">class</span>=<span class="string">"dot"</span>>{<span class="vars">$key</span>+1}#</span>{<span class="vars">$comment</span>.Author.Alias}&nbsp;&nbsp;<span>{<span class="vars">$comment</span>.Time()}&nbsp;<a href=<span class="string">"#comment"</span> onclick=<span class="string">"RevertComment('{$comment.ID}')"</span>>回复</a></span><div <span class="keyword">class</span>=<span class="string">"msgarticle"</span>>{<span class="vars">$comment</span>.Content}</li>
<li class="">{<span class="keyword">foreach</span> <span class="vars">$comment</span>.Comments <span class="keyword">as</span> <span class="vars">$comment</span>}</li>
<li class="alt">{template:comment}</li>
<li class="">{/<span class="keyword">foreach</span>}</li>
<li class="alt"></div></div></div></li>
<li class="">{<span class="keyword">else</span>}</li>
<li class="alt"><span <span class="keyword">class</span>=<span class="string">"dot"</span>>{<span class="vars">$key</span>+1}#</span><a href=<span class="string">"{$comment.Author.HomePage}"</span> rel=<span class="string">"nofollow"</span> target=<span class="string">"_blank"</span>>{<span class="vars">$comment</span>.Author.Name}</a>&nbsp;&nbsp;<span>{<span class="vars">$comment</span>.Time()}&nbsp;<a href=<span class="string">"#comment"</span> onclick=<span class="string">"RevertComment('{$comment.ID}')"</span>>回复</a></span></li>
<li class=""></li>
<li class="alt"></div></li>
<li class=""><div <span class="keyword">class</span>=<span class="string">"msgarticle"</span>>{<span class="vars">$comment</span>.Content}</li>
<li class="alt">{<span class="keyword">foreach</span> <span class="vars">$comment</span>.Comments <span class="keyword">as</span> <span class="vars">$comment</span>}</li>
<li class="">{template:comment}</li>
<li class="alt">{/<span class="keyword">foreach</span>}</li>
<li class=""></div></li>
<li class="alt">{/<span class="keyword">if</span>}</li>
</ol>
</div>
ok,大功告成,效果见上图。
不过我已经弄好了,感谢分享!