HOWTO create sites with opencms

From Chaos

Jump to: navigation, search
This article is part of the HOWTO series.

Contents

Summary

This is a simple article, detailing how to set up a simple OpenCms site. OpenCms is an incredibly powerful CMS system, use Java and some type of DB server (postgresql in my case) for dynmaic content. You can do some very, very powerful things with this CMS system, however, I am only doing a simple example so I can easily remind myself on how I set it up.

Caveats

Details

New Module

First thing's first, create a new module for your new site. If you're site name is www.mydomain.com, browse to /system/modules/, and create a new directory called 'org.mydomain.main'. Within that folder 'org.mydomain.main', create 3 subfolders, elements, resources, templates. These 3 folders will contain various content for your site. A brief rundown is included below.

Module Base
/system/modules/org.mydomain.main
HTML, JSP, JS, etc. Content
/system/modules/org.mydomain.main/elements/
CSS, JPG, GIF, etc. Content
/system/modules/org.mydomain.main/resources/
Dynamic (Template) Content
/system/modules/org.mydomain.main/templates/

main.jsp

Now that we have a directory containing our main site template, go in to /system/modules/org.mydomain.main/templates/, and create a file main.jsp. Put the following info in it.

<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<html>
    <head>
         <cms:editable />
    </head>

    <body>
          <table>
                <tr>
                   <td width='15%'>Static nav stuff!</td>
                   <td width='70%'>
                      <% //Include main page content here! %>
                      <cms:include element="body" editable="true"/>
                   </td>

                   <td width='15%'>
                      <% //Include sidebar content here! %>
                      <cms:include element="side" editable="true"/>
                   </td>
                </tr>
          </table>
    </body>

</html>

New Site

Let's say we want to try and use that template we just created, main.jsp. All we need to do, is:

  1. Go to our site definition directory (I am currently using /sites/test001/ for testing purposes).
  2. Create a content page (page with free text) called index.html.
    1. Name: index
    2. Template: Main Site Page
    3. Copy body from: Leave at default
    4. Edit properties of the new file: True
    5. Append ".html" suffix to name: True
  3. Once you are editing the properties, make sure to fill out the Title, Keywords and Description fields.
  4. After clicking on finish, you can click on the newly created file, index.html to see it's content. By default it will be blank, which is normal. Click on one of the target-signs, and add something to the body and side areas.

Publishing

After making your changes, you have to publish them. Simply right-click on index.html, and chose 'Publish Directly'.


References

Personal tools
Namespaces
Variants
Actions
Navigation
Sponsored Links
Toolbox