HOWTO create sites with opencms
From Chaos
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
- Out of scope for this HOWTO.
- Installing and configuring OpenCms.
- Setting up multiple sites.
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:
- Go to our site definition directory (I am currently using /sites/test001/ for testing purposes).
- Create a content page (page with free text) called index.html.
- Name: index
- Template: Main Site Page
- Copy body from: Leave at default
- Edit properties of the new file: True
- Append ".html" suffix to name: True
- Once you are editing the properties, make sure to fill out the Title, Keywords and Description fields.
- 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'.
