Skip to content

自定义 JSON 数据

✨ 创建 JSON 文件

模版id + .json 文件,如:2005534.json

内容如:

json
{
	"templateMateInfo": "<hlx-template component-type='columnNews' component-query-option='{'columnIds':[],'start':0,'count':100,'showMedium':'PC','columnScope':'SELF'}' component-variable='columnNewsList'></hlx-template>",
	"columnInfo": [
		[# th:each="column,columnStat: ${columnNewsList}"]
		{
			"columnId": "[(${column.id})]",
			"columnName": "[(${column.name})]",
			"columnUrl": "[(${column.urlPc})]",
			"topicImages": "[(${column.listImage})]",
			"list": [
				[# th:each="news,newsStat: ${column.newsList}"]
				{
					"id": "[(${news.newsId})]",
					"title": "[(${news.listTitle})]",
					"imgUrl": "[(${news.listImage})]",
					"url": "[(${news.pcUrl})]",
					"pubTime": "[(${news.pubTime.substring(0,10)})]",
					"summary": "[(${news.summary})]",
					"subTitle": "[(${news.formMap["extend_field_subTitle"]})]",
					"introTitle": "[(${news.formMap["extend_field_introTitle"]})]",
				    "content": "[(${news.content.replace("\n","").replace("\r","").replace("\"","'")})]"
				}[# th:if="!${newsStat.last}"],[/]
				[/]
			]
		}[# th:if="!${columnStat.last}"],[/]
		[/]
	]
}

✨ 新建模版

技术运维管理/模版管理

✨ 生成 url 访问地址

栏目管理/咨询栏目管理

✨ 获取 JSON 数据

方式一:通过 url 访问

方式二:如下

实例

书法协会

轮播图数据

json
{
	"templateMateInfo": "<hlx-template component-type='newsPage' component-query-option='{'columnIds':[5006845],'start':0,'count':5,'showMedium':'PC','listViewCode':['ONE_IMAGE','MULTI_IMAGE']}'  component-variable='newsList'></hlx-template>",
	"data": [
		[# th:each="item,stat: ${newsList}"]
		{
		  "listId": "[(${item.listId})]",
          "newsId": "[(${item.newsId})]",
          "listImage": "[(${item.listImage})]",
          "pubTime": "[(${item.pubTime})]",
          "listImage": "[(${item.listImage})]",
          "listViewCode": "[(${item.listViewCode})]",
          "article":{
            "id": "[(${item.article.id})]",
            "title": "[(${item.article.title})]",
            "summary": "[(${item.article.summary})]",
            "pcUrl": "[(${item.article.pcUrl})]"
          }
		}[# th:if="!${stat.last}"],[/]
		[/]
	]
}