




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、自定義動態(tài)模板頁面在ZCMS中我們的前端頁面不管是靜態(tài)還是動態(tài)的都通過模板來生成,這樣可以很方便的處理各個不同站點的樣式等問題。比如說搜索結果頁面,會員中心頁面等等,這些頁面在不同的站點下雖然都是同樣的功能,但是頁面往往不同。下面我以搜索結果頁面為例介紹一下如何通過模板來實現一個動態(tài)頁面:1) 創(chuàng)建一個模板文件 zsk_search_result.template.html 放到站點的template 目錄下:1<z:if con diti on="$Site .In teractiveHeaderTemplate">2<cms:include file=
2、"$Site.InteractiveHeaderTemplate" />3</z:if>4<div id="mai n" class="pagewidth mai n">5<div class="side_col">6<div class="side_mod">7<h4 class="mod_tit"><z:la ng id="Search.SearchI nSite">站內搜8
3、索 </z:la ngx/h4>9<div class="mod_c on">10<form method="get">11<table width="90%" border="0" align="center"cellpaddi ng="2" cellspaci ng="O">12131415161718192021222324252627<tr><td><z:la ng id
4、="Search.Keyword">關鍵字</z:lang>: </td><td><in put type="text"data-cke-saved-n ame="Query" n ame="Query" class="tex" size="16"value="" suggest="true"suggestsource="Search.suggest" /><
5、;in putdata-cke-saved-name="SitelD"name="SitelD" type="hidde n" value="$Site .I D"></td></tr><tr><td> </td><td> <in put type="submit" value="<z:la ngid='Common.Search'> 搜索 </z:lang>&q
6、uot; class="search_btn" /></td></tr>28</table>29</form>30313233343536373839404142434445</div></div></div><div class="main_col" style="width: 680px;"><data:list method="Search.ListB ind" page="true"
7、; pagesize="20"><div class="crumb"> 有 <b>$ResultTotal</b> 條結果符合<b>$Request.HtmlE ncodeQuery </b>的查詢條件,共耗時:<b>$UseTime</b> 秒。</div><div class="l in e_b"></div><div class="mai nM"><z:list>
8、;<div class="searchResults"><p class="fz16 lin e24"><a target="_bla nk"data-cke-saved-href="$Data.URL" href="$Data.URL">$Data.Title</a></p><p>$Data.Co nten t</p><p><font color="#1a7b2e">
9、<a46data-cke-saved-href="$Data.URL" href="$Data.URL"target="_bla nk">$Data.URL</a> - $Data.PublishDate</fo nt></p>47 -</div>48</z:list>49<div class=" next0825"><data:pagebar></data:pagebar></div></
10、div></data:list></div></div><z:if con diti on="$Site .In teractiveFooterTemplate"><cms:include file="$Site.InteractiveFooterTemplate" /></z:if>2)創(chuàng)建動態(tài)模板解析 UI類SearchResultUI ,添加動態(tài)模板解析方法:1 Priv(login = false)public void result(ZActi on za) thro
11、ws Un supportedE ncod in gExcepti on Stri ng siteid = $V("SitelD");if (!NumberUtil.isL on g(siteid) return;String query =ServletUtil.getChin eseParameter(this.Request.getQueryStri ng(), "Query");if (ObjectUtil.empty(query) query =""this.Request.put("Query", qu
12、ery);this.Request.put("HtmlE ncodeQuery",Strin gUtil.htmlE ncode(query);this.Request.put("URLE ncodeQuery", URLE ncoder.e ncode(query,Con fig.getGlobalCharset();if (ObjectUtil.empty($V("Pagelndex") 345678910111213141516171819this.Request.put("Pagelndex", "
13、;1");2021222324252627282930313233343536Site In dexTemplate srt = new Site In dexTemplate();try AbstractExecuteC on text con text = srt.getC on text(siteid);con text.setPreview(User.isLogi n();con text.setI nteractive(true);if (con text.isPreview()TemplateC on textUtil.addPreviewVariables(c on t
14、ext);else TemplateC on textUtil.addPublishVariables(co ntext, "");con text.addDataVariable("Request", this.Request);con text.setPage In dex(this.Request.getI nt("Page In dex");Stri ng template = "template/zsk_search_result.template.html"AbstractTemplate tpl =C
15、onten tCorePlugi n. getStaticizeC on text() .getTemplateMa nager().fi nd(templ ate);tpl.setC on text(c on text);37tpl.setWriter(za.getResp on se().getWriter();38tpl.execute();39 catch (Exceptio n e) 40e.pri ntStackTrace();za.writeHTML(e.getMessage();在此方法中31行指定了我們需要解析的模板相對站點的路徑。3 )在SearchResultUI類中添加
16、搜索結果列表數據綁定方法:Priv(logi n = false)Alias("Search.ListBi nd") public DataTable getList(AbstractExecuteC on text con text) ArrayList<SearchParam> sps = new ArrayList<SearchParam>();if (ObjectUtil. notEmpty($V("SitelD") SearchParam.SearchType.Equal,6sps.add(new SearchParam
17、("SitelD", $V("SiteID"),Boolea nClause.Occur.MUST);810111213141516171819202122232425if (Stri ngUtil.isNotEmpty($V("Sort") String sorts = StringUtil.splitEx($V("Sort"), ",");for (Stri ng sort : sorts) sps.add( new SearchParam(sort, n ull,SearchParam.S
18、earchType.Sort,Boolea nClause.Occur.MUST);if (ObjectUtil. notEmpty($V("CataloglD")sps.add(new SearchParam("CatalogID", $V("CatalogID"),SearchParam.SearchType.Equal,Boolea nClause.Occur.MUST);else if (ObjectUtil. notEmpty($V("CatalogI nn erCode") sps.add( new S
19、earchParam("CatalogI nn erCode",$V("Cataloglnn erCode"),2627282930313233343536373839404142Stri ng ctype = $V("Co nten tTypelD");if (ObjectUtil.notEmpty(ctype) if (ctype.i ndexOf(",") != -1) Boolea nQuery subQuery = new Boolea nQuery();Stri ng arr = ctype.split
20、(",");for (int i = 0; i < arr.le ngth; i+) Query q = new TermQuery (newTerm("CONTENTTYPE", arri);subQuery.add(q, Boolea nClause.Occur.SHOULD); sps.add( new SearchParam(subQuery,Boolea nClause.Occur.MUST); else sps.add( new SearchParam("CONTENTTYPE", ctype,SearchParam
21、.SearchType.Equal,Boolea nClause.Occur.MUST);if (Stri ngUtil.isNotEmpty($V("Query") sps.add(new SearchParam("Title", $V("Query"),SearchParam.SearchType.Fulltext, Boolean Clause.Occur.MUST);sps.add(new SearchParam("Status", String.valueOf(3O),SearchParam.Search
22、Type.Equal,Boolea nClause.Occur.MUST);sps.add( new SearchParam("l ndexE nable", "Y",SearchParam.SearchType.Equal,Boolea nClause.Occur.MUST);sps.add( new SearchParam("PageSize", con text.getPageSize()+"",SearchParam.SearchType.PageSize);43444546474849505152535455565758sps.add( new SearchParam("Page In dex", con text.getPage In dex()+"",SearchParam.SearchType.Pageln dex);59606162636465666768697071SearchResult sr = SearchService.search(sps, true);con text.setPageTotal(sr.Total);con text.addDataVariable("UseTime"
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 供貨茶葉合同范本
- 包裝食品配送合同范例
- 合作擔保合同范例
- 合租合同范本
- 化肥合作協(xié)議合同范本
- 廠房使用合同范例
- 人工勞務合同范本封皮
- 個人汽車采購合同范本
- 企業(yè)業(yè)務合同范本
- 合同范本征求意見
- 【講座培訓】《中小學教育懲戒規(guī)則(試行)》解讀課件
- 中科大《無機化學》課件1氣體、液體和溶液的性質
- 復婚合同協(xié)議書模板
- U8-EAI二次開發(fā)說明
- 2006 年全國高校俄語專業(yè)四級水平測試試卷
- 浙江省勞動保障監(jiān)察員培訓監(jiān)察執(zhí)法程序(林琳)
- 新人教版數學四年級下冊全冊表格式教案
- 閩教版(2020版)六年級下冊信息技術整冊教案
- 二手房買賣合同正式版空白
- 食品銷售經營者食品安全管理制度(零售)
- 通信電源-概述ppt課件
評論
0/150
提交評論