輕開平台:可調用標籤,平台叫用標籤
只需給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的功能,請留意最新的開發手冊