PHPCMS V9栏目有关键词和描述就显示没有就显示当前栏目名字

来自:互联网
时间:2018-09-02
阅读:
免费资源网 - https://freexyz.cn/

思路如下:

先用正则匹配,如果有数据就输出$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}
免费资源网 - https://freexyz.cn/
返回顶部
顶部