首页 新闻 会员 周边

为什么有些网站的页面的html不直接写在上面,还是用StringBuilder拼接起来再输出

0
[已关闭问题]

templateBuilder.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n");
    templateBuilder.Append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n");
    templateBuilder.Append("<head>\r\n");
    templateBuilder.Append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n");
    templateBuilder.Append("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=7\" />\r\n");
    templateBuilder.Append(meta.ToString());
    templateBuilder.Append("\r\n");

    if (pagetitle == "首页")
    {

        templateBuilder.Append("<title>");
        templateBuilder.Append(config.Forumtitle.ToString().Trim());
        templateBuilder.Append(" ");
        templateBuilder.Append(config.Seotitle.ToString().Trim());
        templateBuilder.Append(" - Powered by Discuz!NT</title>\r\n");

    }
    else
    {

        templateBuilder.Append("<title>");
        templateBuilder.Append(pagetitle.ToString());
        templateBuilder.Append(" - ");
        templateBuilder.Append(config.Forumtitle.ToString().Trim());
        templateBuilder.Append(" ");
        templateBuilder.Append(config.Seotitle.ToString().Trim());
        templateBuilder.Append(" - Powered by Discuz!NT</title>\r\n");

    } //end if

    templateBuilder.Append("<link rel=\"icon\" href=\"");
    templateBuilder.Append(forumurl.ToString());
    templateBuilder.Append("favicon.ico\" type=\"image/x-icon\" />\r\n");
    templateBuilder.Append("<link rel=\"shortcut icon\" href=\"");
    templateBuilder.Append(forumurl.ToString());
    templateBuilder.Append("favicon.ico\" type=\"image/x-icon\" />\r\n");
    templateBuilder.Append("<!-- 调用样式表 -->\r\n");
    templateBuilder.Append("<link rel=\"stylesheet\" href=\"");
    templateBuilder.Append(forumurl.ToString());
    templateBuilder.Append("templates/");
    templateBuilder.Append(templatepath.ToString());
    templateBuilder.Append("/dnt.css\" type=\"text/css\" media=\"all\"  />\r\n");
    templateBuilder.Append(link.ToString());
    templateBuilder.Append("\r\n");
    templateBuilder.Append("<script type=\"text/javascript\" src=\"");
    templateBuilder.Append(forumurl.ToString());
    templateBuilder.Append("javascript/template_report.js\"></");
    templateBuilder.Append("script>\r\n");
    templateBuilder.Append("<script type=\"text/javascript\" src=\"");
    templateBuilder.Append(forumurl.ToString());
    templateBuilder.Append("javascript/template_utils.js\"></");
    templateBuilder.Append("script>\r\n");
    templateBuilder.Append("<script type=\"text/javascript\" src=\"");
    templateBuilder.Append(forumurl.ToString());
    templateBuilder.Append("javascript/common.js\"></");
    templateBuilder.Append("script>\r\n");
    templateBuilder.Append("<script type=\"text/javascript\" src=\"");
    templateBuilder.Append(forumurl.ToString());
。。。。。

拖鞋王子的主页 拖鞋王子 | 初学一级 | 园豆:37
提问于:2010-03-30 23:49
< >
分享
其他回答(3)
0

这是创建动态网站的一种方式,不过个人觉得这种方式很不利于维护。

Joe_true | 园豆:98 (初学一级) | 2010-03-31 09:41
0

templateBuilder,起名就模版,人各有做法,每种做法只属于某些。。

路过秋天 | 园豆:4787 (老鸟四级) | 2010-03-31 09:49
0

你这段代码出自 Discuz!NT,这个是他们使用的模板机制处理的。个人觉得他们这么处理是为了更好的灵活性.比如一般见到的http://www.discuz.net/forum-29-1.html 中forum-29-1.html  这个页面,他其实是不存在的,动态由这些模板输出的。

西越泽 | 园豆:10775 (专家六级) | 2010-03-31 10:08
0
黑白之间 | 园豆:859 (小虾三级) | 2010-03-31 17:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册