首页 > 代码库 > 轻开平台:可调用标签

轻开平台:可调用标签

只需给Chtml(ChinaHtml)标签增加一个id,

<chtml file=文件名 id=callme onlycall />
<chtml>
<call>callme</call>
</chtml>

就可以用call标签调用,详见后边章节的call标签介绍

(例子文件:_samples/call.html)

在实际开发中的例子:

一个体育手机APP项目服务端统计分组排名的json格式代码:

登录判断,用户未登录就跳转到错误处理json,若登录则调用id=ok的标签

{<chtml><session><we name=user_id>222</we></session>
<if x="@{session:user_id}" else=1>
	<to>@{sys:path}@{curl:usr/error.json?err=login}</to>
	<call>ok</call>
</if>
</chtml>}
id=ok的标签

<chtml id=ok onlycall>
<if x="@{pPage:group_id}" else=1>
	<bag id=pPage><we name=group_id>0</we></bag>
	<bag id=pPage><we name=group_id>@{trim:@{pPage:group_id}}</we></bag>
</if>
<!-- 每页的长度 -->
<Bag id=pPage><we name=length>10</we></Bag><!-- 取总数等 -->
<esql module=base id=count1>
<![CDATA[
select count(user_id) all_id from (
	......
	) t0 on user_id=t0.we_id group by user_id
) t1
]]>
</esql>
<!-- 总页数和最后一页的条数 -->
<bag id=pPage>
	<we name=pages>@{int:@{count1:all_id}/@{pPage:length}}</we>
	<we name=odd>@{int:@{count1:all_id}%@{pPage:length}}</we>
</bag>
<if x="@{pPage:odd}" else=1>
	<bag id=pPage x=0><we name=odd>@{pPage:length}</we></bag>
	<bag id=pPage><we name=pages>@{int:@{pPage:pages}+1}</we></bag>
</if>
<!-- 开始页 -->
<if x="@{pPage:page}" else=1>
	<Bag id=pPage><we name=start>0</we></Bag>
	<Bag id=pPage><we name=start>@{int:@{pPage:page}*@{pPage:length}-@{pPage:length}}</we></Bag>
</if>
<if x="@{logic:@{pPage:start}<0}"><Bag id=pPage x=true><we name=start>0</we></Bag></if>
<!-- 如果最后一页不足,就取实际条数 -->
<if x="@{int:@{pPage:start}/@{pPage:length}+1}">
	<bag id=pPage x="@{pPage:pages}"><we name=length>@{pPage:odd}</we></bag>
</if>
<if x="@{pPage:start}" else=1>
	<call x="0">one</call>
	<call>more</call>
</if>
</chtml>
如果是第一页就调用id=one的标签,否则就调用id=more的标签

<if x="@{pPage:start}" else=1>
	<call x="0">one</call>
	<call>more</call>
</if>
id=one及id=more的标签
<chtml file="@{sys:curPath}rank_group_one.json" id=one onlycall />
<chtml file="@{sys:curPath}rank_group_more.json" id=more onlycall />

one跟more标签文件略...

测试数据输出结果:

{"rank_myself":{"rank":"1","userName":"小样","mobile":"13261907030","picuri":"/usr/photos/usr222_j5Gx4OKsFg66.jpg","city":"河北略","sex":"M","under":"25","role":"","brassieAvgNum":"70.4","brassieMinNum":"19:1","fairWayRate":"37%:1","distanceMax":"329:1","putAvgNum":"1.3:1","countNum":18},"rankInfos":[{"rank":"1","userName":"小样","mobile":"13261907030","picuri":"/usr/photos/usr222_j5Gx4OKsFg66.jpg","city":"河北河北略","sex":"M","under":"25","role":"","brassieAvgNum":"70.4","brassieMinNum":"19:1","fairWayRate":"37%:1","distanceMax":"329:1","putAvgNum":"1.3:1","countNum":18}],"pageCount":"1","memo":"群组排名"}
调用标签和引入文件都相当Easy吧!

轻开平台资源下载及说明

平台免费下载:http://download.csdn.net/detail/tx18/8381859

最新开发手册下载:http://download.csdn.net/detail/tx18/8411089

开发实例:轻开B2C电子商务网站,免费下载:http://download.csdn.net/detail/tx18/8318585

轻开平台会不定期升级为大家提供更多强大而Easy的功能,请留意最新的开发手册

轻开平台:可调用标签