时间:2021-07-01 10:21:17 帮助过:39人阅读
twig:
{
"base_resp":
{
"ret":{{ baseResp.ret }},
"err_msg":"{{ baseResp.errMsg }}"
},
"app_msg_info":
{
"item":
[
{% if weixinNewses is not empty %}
{% for weixinNews in weixinNewses %}
{
"seq":{{ weixinNews.id }},
"app_id":{{ weixinNews.id }},
"file_id":{{ weixinNews.id }},
"title":"{{ weixinNews.title }}",
"digest":"{{ weixinNews.digest }}",
"create_time":"{{ weixinNews.createdTime|datetimeToSecond }}",
"multi_item":
[
{
"seq":{{ weixinNews.id }},
"cover":"{{ weixinNews.thumbMediaUrl }}"
……
}
],
"content_url":"{{ weixinNews.detailUrl }}",
"img_url":"{{ weixinNews.thumbMediaUrl }}",
"author":"{{ weixinNews.author }}",
"show_cover_pic":1,
"update_time":"{{ weixinNews.updatedTime|datetimeToSecond }}"
},
{% endfor %}
{#这里要有{}#}
{}
{% endif %}
],
"file_cnt":
{
"total":{{ fileCnt.total }},
"img_cnt":{{ fileCnt.imgCnt }}
……
},
"is_upload_cdn_ok":{{ appMsgInfo.isUploadCdnOK }},
"search_cnt":{{ appMsgInfo.searchCnt }}
}
}
action:
/**
* 加载更多图文
* @Template()
* @param Request $request
* @Route("/xxx,name="xxx")
* @return array
*/publicfunctiongetWeixinNewsesHtmlAction(Request $request){$weixinNewses=xxx;//微信图文信息$baseResp = array("ret"=>$ret,"errMsg"=>$errMsg);
$fileCnt = array(
"total"=>$count,
"imgCnt"=>0,
"voiceCnt"=>0,
"videoCnt"=>0,
"appMsgCnt"=>$count,
"commondityMsgCnt"=>0,
"videoMsgCnt"=>0,
"shortVideoCnt"=>0,
"appMsgSentCnt"=>0
);
$appMsgInfo = array("isUploadCdnOK"=>0,
"searchCnt"=>empty($query)?0:$count
);
returnarray(("baseResp"=>$baseResp,"fileCnt"=>$fileCnt,"weixinNewses"=>$weixinNewses,"appMsgInfo"=>$appMsgInfo));
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了使用twig来组装数据使数据结构可视化,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。