Search code examples
jsptemplatesopencms

OpenCMS JSP template


I am using opencms 10.

Well have created simple jsp template by following this link

<%@page buffer="none" session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html>
    <head>

        <cms:enable-ade />

    </head>
    <body>

        <div id="header">
            <cms:container name="headercontainer" type="header" maxElements="1" />      
        </div>

        <div id="window">
            <cms:container name="centrecontainer" type="center" maxElements="8" detailview="true"/>
        </div>

        <div id="footerColumn">
            <cms:container name="footercontainer" type="footer" maxElements="1"/>
        </div>
    </body>
</html>

say it is main.jsp. After this I created a new container-page say my-fist-template.html and set following property

template = /system/modules/my.first.module/templates/main.jsp

Then I created a new resource type say myResourceType. I also created xsd and formatter for newly created resource type.

After this I opened my-fist-template.html for editing. I was unable to add layout, simple slider, flexible content etc (every/default resource types created by opencms) BUT I was able to put my newly created resource type myResourceType.

What am I missing?


Solution

  • If you change container type to area or element then you would be able to place layouts or resource types respectively. Something like below

    <cms:container name="mycontainer" type="area" maxElements="1"/> // Here you can put layouts (and then other resource types into the layouts)
    
    <cms:container name="myothercontainer" type="element" maxElements="1"/> // Here you can put resource types into the container directly
    

    Hope this helps