外部网站调用CMS数据

2024-01-26 16:26 小编

在外部网站或者静态html页面上调用迅睿cms数据方法


1、在迅睿cms中开启开发者模式,index.php开启

2、然后访问迅睿cms首页,并查看源代码,如下图:

外部网站调用CMS数据

3、按照上图红线地址,创建一个模板

/template/pc/default/home/api/waibu.html


4、模板内容,随便写,你可以用标签查询news模块的数据,例如

{module module=news num=10} <a href="{$t.url}">{$t.title}</a>{/module}

5、然后在外部网站或者静态html页面加入以下代码,就可以读取到迅睿cms内容了

<div id="xunruicms_news"></div>

<script type="text/javascript">

    $.ajax({

        type: "GET",

        url:"http://网站.com/index.php?s=api&c=api&m=template&name=waibu.html&format=jsonp",

        dataType: "jsonp",

        success: function(json){

            $("#xunruicms_news").html(json.msg);

        },

        error: function(){ }

    });

</script>

页面需要提前加载jquery


Tag: 数据 网站
在线咨询 拨打电话

电话

13363039260

微信二维码

微信二维码