Toggle navigation
首页
技术
骑行
羽毛球
资讯
联络我
登录
Craft CMS之json
2017-07-27
CraftCMS
# 直接使用twig生成json ```html {% set pages = craft.entries('pages') [ {% for page in pages %} { "title":"{{page.title}}", "slug":"{{page.slug}}" } {% if not loop.last %} , {% endif %} {% endfor %} ] ``` # 使用插件将entities转换为json ## setup plug-in https://github.com/mattstauffer/craftcms-prune 1. Move the prune directory into your craft/plugins directory. 2. Go to Settings > Plugins from your Craft control panel and enable the prune plugin ## usage ```html {{ pages | prune(['title', 'slug']) | json_encode() | raw }} ```
×
本文为博主原创,如需转载,请注明出处:
http://www.supperxin.com
返回博客列表