思路如下:
先用正则匹配,如果有数据就输出$SEO['keyword'],否则就输出$CATEGORYS[$catid][catname]。
完整代码如下:
{pc:get sql="select `setting` FROM `v9_category` WHERE `catid`=$catid" num="1" siteid="$siteid"} {loop $data $v} {php preg_match("/meta_keywords":"(.+)","meta_description/", $v[setting], $rs);} {if $rs[1]} <meta name="keywords" content="{$SEO['keyword']}" /> {else} <meta name="keywords" content="{$CATEGORYS[$catid][catname]}" /> {/if} {/loop} {/pc} {pc:get sql="select `setting` FROM `v9_category` WHERE `catid`=$catid" num="1" siteid="$siteid"} {loop $data $v} {php preg_match("/meta_description":"(.+)","presentpoint/", $v[setting], $rs);} {if $rs[1]} <meta name="description" content="{$SEO['description']}" /> {else} <meta name="description" content="{$CATEGORYS[$catid][catname]}" /> {/if} {/loop} {/pc}