昨天接一个zblogphp淘客店铺导航站定制,其中用到了编辑文章页面添加信用数字,前台显示信用图片,今天来记录分享出来:
以上就是信用图片,淘宝的信用图都对应相应的信用数字,如:
前台要转换为:
后台编辑为:
其中用到了信用数字转换为图片,我是这么做的:
1、先为文章编辑中加入信用字段:
include.php挂载:
Add_Filter_Plugin('Filter_Plugin_Edit_Response5','ydtao_article_tao');
2、加入:
function ydtao_article_tao(){ global $zbp,$article; echo '<p>掌柜: <input type="text" style="width:30%;" name="meta_zhanggui" value="'.$article->Metas->zhanggui.'"/></p>'; echo '<p>信用: <input type="text" style="width:30%;" name="meta_xinyong" value="'.$article->Metas->xinyong.'"/></p>'; echo '<p>行业: <input type="text" style="width:30%;" name="meta_hangye" value="'.$article->Metas->hangye.'"/></p>'; echo '<p>网址: <input type="text" style="width:80%;" name="meta_url" value="'.$article->Metas->url.'"/></p>'; }
3、为前台模板中加入<img src='下方代码单独文件'>
4、建一个单独的模板文件,放入下方这些判断,用数值判断范围,显示对应图片:
<?php echo'404';die();?>{if $article.Metas.xinyong>4&&$article.Metas.xinyong<10 } {$host}zb_users/theme/{$theme}/style/img/tao/s_red_1.gif {elseif $article.Metas.xinyong>11&&$article.Metas.xinyong<40 } {$host}zb_users/theme/{$theme}/style/img/tao/s_red_2.gif {elseif $article.Metas.xinyong>41&&$article.Metas.xinyong<90 } {$host}zb_users/theme/{$theme}/style/img/tao/s_red_3.gif {elseif $article.Metas.xinyong>91&&$article.Metas.xinyong<150 } {$host}zb_users/theme/{$theme}/style/img/tao/s_red_4.gif {elseif $article.Metas.xinyong>151&&$article.Metas.xinyong<250 } {$host}zb_users/theme/{$theme}/style/img/tao/s_red_5.gif {elseif $article.Metas.xinyong>251&&$article.Metas.xinyong<500 } {$host}zb_users/theme/{$theme}/style/img/tao/s_blue_1.gif {elseif $article.Metas.xinyong>501&&$article.Metas.xinyong<1000 } {$host}zb_users/theme/{$theme}/style/img/tao/s_blue_2.gif {elseif $article.Metas.xinyong>1001&&$article.Metas.xinyong<2000 } {$host}zb_users/theme/{$theme}/style/img/tao/s_blue_3.gif {elseif $article.Metas.xinyong>2001&&$article.Metas.xinyong<5000 } {$host}zb_users/theme/{$theme}/style/img/tao/s_blue_4.gif {elseif $article.Metas.xinyong>5001&&$article.Metas.xinyong<10000 } {$host}zb_users/theme/{$theme}/style/img/tao/s_blue_5.gif {if $article.Metas.xinyong>10001&&$article.Metas.xinyong<20000 } {$host}zb_users/theme/{$theme}/style/img/tao/s_cap_1.gif {elseif $article.Metas.xinyong>20001&&$article.Metas.xinyong<50000} {$host}zb_users/theme/{$theme}/style/img/tao/s_cap_2.gif {elseif $article.Metas.xinyong>50001&&$article.Metas.xinyong<100000} {$host}zb_users/theme/{$theme}/style/img/tao/s_cap_3.gif {elseif $article.Metas.xinyong>100001&&$article.Metas.xinyong<200000} {$host}zb_users/theme/{$theme}/style/img/tao/s_cap_4.gif {elseif $article.Metas.xinyong>200001&&$article.Metas.xinyong<500000} {$host}zb_users/theme/{$theme}/style/img/tao/s_cap_5.gif {elseif $article.Metas.xinyong>500001&&$article.Metas.xinyong<1000000} {$host}zb_users/theme/{$theme}/style/img/tao/s_crown_1.gif {elseif $article.Metas.xinyong>1000001&&$article.Metas.xinyong<2000000} {$host}zb_users/theme/{$theme}/style/img/tao/s_crown_2.gif {elseif $article.Metas.xinyong>2000001&&$article.Metas.xinyong<5000000} {$host}zb_users/theme/{$theme}/style/img/tao/s_crown_3.gif {elseif $article.Metas.xinyong>5000001&&$article.Metas.xinyong<10000000} {$host}zb_users/theme/{$theme}/style/img/tao/s_crown_4.gif {elseif $article.Metas.xinyong>10000001} {$host}zb_users/theme/{$theme}/style/img/tao/s_crown_5.gif {else}{/if}