Because the younger brother to write a method is still very easy, but for the front-end related things are not very understand, in my own Tongliang window This small station, involving each channel a template, each channel related page is a template, little brother HTML written on aspx above, Then in the matching template to find a lot of some templates can be common, such as the head of the home page, there are other channels head section, as well as the footer part, so write the following a thing to control each page template call, do not know right ha. Would you please enlighten me!
By the way, during the operation, my server will generate 1% of disk fragments per month, and I don't know if it's related to this template scheme.
<summary>//dir is a sub-folder under the template directory, shop,m, and other///</summary>/<param name= "D IR "></param>//<param name=" TPL "></param>//<returns></returns> public static string Getpagecontent (String dir, String tpl) {string key = Dir + "_" + TPL + "_content"; String contentkey = dir + "_content_content"; String temp = ""; if (Datacache.getcache (key) = = NULL) {string filepath = "/template/" + dir + (dir). Length > 0? "/": ") + TPL +". html "; temp = File.readalltext (HttpContext.Current.Server.MapPath (filepath), Encoding.UTF8); Datacache.setcache (key, temp); } else {temp = Datacache.getcache (key). ToString (); } String content = ""; if (Datacache.getcache (contentkey) = = null) {content = File.readalltext (HttpContext.Current.Server.MapPath ("/template/" + dir + "/content.html"), Encoding.UTF8); Datacache.setcache (Contentkey, content); } else {content = Datacache.getcache (Contentkey). ToString (); } String html = content. Replace ("< $inner $>", temp); String headstr = (string) datacache.getcache ("Headcontent"); String footstr = (string) datacache.getcache ("Footcontent"); if (Headstr = = NULL | | footstr = = NULL) {Headstr = File.readalltext (HttpContext.Current.Server. MapPath ("/template/head.html"), Encoding.UTF8); Footstr = File.readalltext (HttpContext.Current.Server.MapPath ("/template/foot.html"), Encoding.UTF8); Datacache.setcache ("Headcontent", headstr); Datacache.setcache ("Footcontent", footstr); } HTML = HTML. Replace ("< $footcontent $>", Footstr); html = HTML. Replace ("< $headcontent $>", headstr); if (!string. IsNullOrEmpty (dir)) {Cms_seo SEO = Getcurrectseo (dir); html = HTML. Replace ("< $seoname $>", seo. SiteName); html = HTML. Replace ("< $seourl $>", seo. SiteURL); html = HTML. Replace ("< $seoaddress $>", seo. Address); html = HTML. Replace ("< $seocopyright $>", seo. Copyright); html = HTML. Replace ("< $seodescription $>", seo. Description); html = HTML. Replace ("< $seoemail $>", seo. Email); html = HTML. Replace ("< $SEOICP $>", seo. ICP); html = HTML. Replace ("< $seokeywords $>", seo. Keywords); html = HTML. Replace ("< $seologo $>", seo. Logo); html = HTML. Replace ("< $seotel $>", seo. Tel); html = HTML. Replace ("< $seoweixin $>", seo. Weixin); html = HTML. Replace ("< $seOworktime$> ", SEO. Worktime); html = HTML. Replace ("< $OnlineChart $>", seo. Onlinechart); } HTML = HTML. Replace ("< $token $>", DateTime.Now.AddHours (1). Ticks + ""); Ad bit HTML = HTML. Replace ("< $DetailBottom $>", Getadscript ("Detailbottom")); html = HTML. Replace ("< $RightContent $>", Getadscript ("rightcontent")); html = HTML. Replace ("< $BottomAd $>", Getadscript ("Bottomad")); Ad bit End html = new Bll_adv (). Getplacetag (HTML, dir); return HTML; }
Younger brother program is not fine, please take care, by the way look at the little brother's station what to improve---"Tongliang windows
C # write an HTML template scheme, do not know what you use on the ASP is the same principle