淘宝商城月销5000件

OpenCms运行环境

OpenCms运行环境

TemplateTwo 模板文件main.jsp介绍

作者【袁海明】 时间【2009-12-12】 浏览【2,349】

使用OpenCms TemplateTwo创建的网站,整个网站都由一个模板文件main.jsp控制,下面是main.jsp的内容和说明:

<%@page buffer="none" session="false" import="org.opencms.frontend.templatetwo.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %><%

    // The main template JSP of TemplateTwo.
    // This template is highly configurable in style and layout. The configuration
    // is done in several configuration files of the types "ttstyle", "ttconfig",
    // "ttoptions" and "ttpreset". Those configuration files are managed by the
    // class CmsTemplateLayout.
    //
    // For details on the CmsTemplateLayout class, see the source code which can
    // be found at the following VFS location:
    // /system/modules/org.opencms.frontend.templatetwo/java_src/CmsTemplateLayout.java

    CmsTemplateLayout cms = new CmsTemplateLayout(pageContext, request, response);
    pageContext.setAttribute("cms", cms);
%>
<cms:template element="head">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    通过属性设置页面标题、描述、关键字等页面信息
    <title><cms:property name="Title" file="search" /></title>
    <meta name="description" content="<cms:property name="Description" file="search" />" >
    <meta name="keywords" content="<cms:property name="Keywords" file="search" />" >
    <meta http-equiv="Content-Type" content="text/html; charset=${cms.requestContext.encoding}" >
    <meta name="robots" content="index, follow" >
    <meta name="revisit-after" content="7 days" >

    添加模板所需的CSS文件
    <!-- insert stylesheets needed for the template -->
    <c:forEach items="${cms.stylesheets}" var="cssFile">
        <link href="<cms:link>${cssFile}</cms:link>" rel="stylesheet" type="text/css">       
    </c:forEach>

    添加控制网站样式的主要CSS文件      
    <link href="<cms:link>../resources/css/style.css?preset=${cms.presetPath}&amp;style=${cms.stylePath}</cms:link>" rel="stylesheet" type="text/css">
    添加IE CSS补丁文件
    <!--[if lte IE 6]>
        <link href="<cms:link>%(link.weak:/system/modules/org.opencms.frontend.templatetwo/resources/css/patch_ie.css:8ffaafcc-e131-11dc-bbcd-3bdd2ea0b1ac)</cms:link>" rel="stylesheet" type="text/css">
    <![endif]-->

    加载通过stylesheet属性设置的CSS文件
    <!-- insert individual stylesheet -->
    <c:set var="stylesheet"><cms:property name="stylesheet" file="search"/></c:set>
    <c:if test="${!empty stylesheet}">
        <link href="<cms:link>${stylesheet}</cms:link>" rel="stylesheet" type="text/css">
    </c:if>
    设置页面允许前台编辑
    <cms:editable/>
</head>

<body>
    <div id="window">
        <div id="page">
             
            <!-- begin: header -->
            <div id="header">
            添加options文件中设置的顶部导航到页面中
                <div id="topnav">
                    <a href="#content">Skip to Main Content</a>
                    <c:if test="${!cms.options.value['TopNav'].isEmptyOrWhitespaceOnly}">
                        <c:out value="${cms.options.value['TopNav']}" escapeXml="false" />
                    </c:if>
                </div>
            添加页眉信息
                <c:if test="${!cms.options.value['Header'].isEmptyOrWhitespaceOnly}">
                    <c:out value="${cms.options.value['Header'].resolveMacros}" escapeXml="false" />
                </c:if>
            </div>
            <!-- end: header -->
            添加页面导航
            <!-- begin: main navigation -->
            <c:choose>
                <c:when test="${!empty cms.styleValue['nav.main']}">
                    <cms:include file="${cms.styleValue['nav.main']}"/>
                </c:when>
                <c:otherwise>
                    <cms:include file="%(link.weak:/system/modules/org.opencms.frontend.templatetwo/elements/menu/nav_style2.jsp:ee5498d9-dbe4-11dc-b087-3bdd2ea0b1ac)"/>
                </c:otherwise>
            </c:choose>
            <!-- end: main navigation -->
            添加导航链
            <!-- begin: breadcrumb -->
            <div id="breadcrumb">
                <cms:include file="%(link.weak:/system/modules/org.opencms.frontend.templatetwo/elements/breadcrumb.jsp:e72c6f1c-dbb3-11dc-af66-3bdd2ea0b1ac)" />
            </div>
            <!-- end: breadcrumb -->
           
            <!-- begin: content area #main -->
            <div id="main">
            页面左列开始
            <!-- begin: left column -->
            <div id="col1">
                <div id="col1_content">
                    <c:if test="${cms.presetValue['column.left.visible'] == 'true'}">
                        添加左侧子栏目导航
                        <!-- include the left navigation menu -->
                        <c:if test="${cms.presetValue['nav.left.visible'] == 'true'}">
                            <cms:include file="%(link.weak:/system/modules/org.opencms.frontend.templatetwo/elements/menu/nav_left.jsp:ee1ea4f4-d97c-11dc-bc65-3bdd2ea0b1ac)" />
                        </c:if>
                        添加左侧列区块信息
                        <!-- include the boxes on the left side -->
                        <cms:include file="%(link.weak:/system/modules/org.opencms.frontend.templatetwo/elements/boxes.jsp:622548e8-d886-11dc-8ec1-3bdd2ea0b1ac)">
                            <cms:param name="orientation" value="left" />
                            <cms:param name="config" value="${cms.configPath}" />
                        </cms:include>
                    </c:if>
                </div>
            </div>
            <!-- end: left column -->
            页面右列开始
            <!-- begin: right column -->
            <div id="col3">
                <div id="col3_content">
                    <c:catch>
                        <c:set var="page" value="${cms:vfs(pageContext).readXml[cms:vfs(pageContext).context.uri]}" />
                    </c:catch>
                    添加右侧列区块信息
                    <!-- include the boxes on the right side -->
                    <c:if test="${cms.presetValue['column.right.visible'] == 'true'}">
                        <cms:include file="%(link.weak:/system/modules/org.opencms.frontend.templatetwo/elements/boxes.jsp:622548e8-d886-11dc-8ec1-3bdd2ea0b1ac)">
                            <cms:param name="orientation" value="right" />
                            <cms:param name="config" value="${cms.configPath}" />
                        </cms:include>
                    </c:if>
               </div>
            </div>
            <!-- end: right column -->
            页面中间列开始
            <!-- begin: center column -->
            <div id="col2">
                <div id="col2_content">
                    <!-- anchor for accessible link to main content -->
                    <a id="content" name="content"></a>
</cms:template>
添加可编辑区body
<cms:template element="body">
    <cms:include element="body" editable="true"/>
</cms:template>

<cms:template element="foot">
                    添加可编辑区body2
                    <!-- include the second body from an xml page, if available -->
                    <c:if test="${page.hasValue['body2']}">
                        <cms:include element="body2" editable="true"/>
                    </c:if>
                    添加中间列区块信息
                    <!-- include the boxes in the center -->
                    <cms:include file="%(link.weak:/system/modules/org.opencms.frontend.templatetwo/elements/boxes.jsp:622548e8-d886-11dc-8ec1-3bdd2ea0b1ac)">
                        <cms:param name="orientation" value="center" />
                        <cms:param name="config" value="${cms.configPath}" />
                    </cms:include>
                </div>
                <div>&nbsp;</div>
            </div>
            <!-- end: center column -->
        </div>
        <!-- end: content area -->
        添加页脚信息
        <!-- begin: #footer -->
        <div id="footer">
            <c:if test="${!cms.options.value['Footer'].isEmptyOrWhitespaceOnly}">
                <c:out value="${cms.options.value['Footer'].resolveMacros}" escapeXml="false" />
            </c:if>
        </div>
        <!-- end: #footer -->
       
    </div>
    <!-- end: #page -->
</div>
</body>
</html>
</cms:template>

1 条评论 »

  1. vinod - 2010年09月16日 @ 8:33 下午

    Hi,

    I am relay appreciate your help, I am new to Opencms and I am a designer i was trying to develop template i success in it. problem is i differentiate the CSS in separate files when i went through “Template Two” “Load thorugh css attribute” or “” method which works for loading one css file at a time i want to add more then one by semicolen or comma to separate the css for one template.
    can you please help me on this.

    thanks in advance (vinod) indianwala at krify dot com