OpenCms 9.5 (and soon version 10) has a great number of features that are included in the core distribution but are not well known and therefore often remain unused. These include:
- Many EL functions available for JSP templates
- XML schema based configuration of the content editor
- Individual content settings for sitemaps
- Advanced logging options in the workplace Administration
… and much more.
In this session, some of these valuable hidden features are presented.
6. ● Access to OpenCms core beans in your
JSP/Formaters
See the updated documentation and JavaDoc!
● Mostly used: ContentAccessBean, easy access
to XML contents:
● <cms:formatter var="content"> ... </cms:formatter>
● <cms:contentload ...> ... <cms:contentaccess
var="content" /> ... </cms:contentload>
6
EL functions
7. ● CmsJspStandardContextBean cms
● Default entry point to EL functions, get access to other beans
● Some interesting properties of CmsJspStandardContextBean
● cms.locale
the locale for the current request
● cms.title
the title property of currently requested page (containerpage)
● cms.uri
Uri of the requested resource
● cms.isOnlineProject
check if you are in the online project
● cms.isEditMode
check if edit mode is enabled
● and much more…
7
EL functions
8. ● Access to other useful beans:
● cms.requestContext
returns a request context bean with properties
● uri
Uri of the requested resource
● currentUser
Returns a bean with information about the current user
● and much more…
● cms.vfs
Returns a VFS bean that allows to explore the VFS
● Some resource
cms.vfs.resource[<site relative path>]
● Currently requested resource
cms.vfs.resource[cms.requestContext.uri]
8
EL functions
9. ● Useful Beans for containers and elements
● cms.page (CmsContainerPageBean)
currently rendered container page
● cms.container (CmsContainerBean)
Get information on the container you are in
● cms.element (CmsContainerElementWrapper)
Get information for the currently rendered
container page element
● See the JavaDoc for all available methods
9
EL functions
10. How to configure content locations and content
types
Individual content settings for
sitemaps
10
11. ● „Behaviour“ of content types is defined in
module config and can be overwritten in the
sitemap configuration
● Local content = store content in current
sitemap/.content folder
11
Individual content settings for
sitemaps
12. ● Disable individual content types (useful in a
multi-site enviroment)
12
Individual content settings for
sitemaps
13. ● Disable all content types and set them
individually
13
Individual content settings for
sitemaps
15. ● OpenCms uses log4j for logging
● Default: opencms.log in /logs folder
● Tool for non persistant changes in
Workplace Admin-View
● Only for Workplace Server!
● Customers called it: “Starship Enterprise”
15
Logging Tool in Workplace
19. ● Dynamic XML-Sitemap
generation
● Uses all
Containerpages which
are part of the
navigation
● Additionally, all
permutations of
Detailpages are added
(eg. News)
19
The XML-Sitemap
20. 20
Extending the XML-Sitemap
● Container page dates: Calculate last modification date
based on elements used on the Containerpage (slower)
● Sitemap generator class: Custom additions to sitemap
21. ● Extend the class
org.opencms.site.xmlsitemap.CmsXmlSitemapGenerator
● Overwrite method
getInnerXmlForEntry(CmsXmlSitemapUrlBean entry)
Create individual additional output for each entry of the
Sitemap
● Example from real life project:
● Multiple Sites in OpenCms which show identical content in
different locales
Solution: Refer to same content in same or other locale XML-
Sitemap with „alternate“ attribute
21
Extending the XML-Sitemap
24. ● <cms:parse> allows to modify the HTML output of
content elements during delivery
● No changes to the content itself is made!
● Typical examples:
● Modification of Links
● (mailto Link -> Link to webform)
● Addition/modification of class attributes
● (internal/external links)
● Adjustments in the Text
● (replacement of shortcuts)
24
The <cms:parse> tag
25. ● Usage in formatter:
● Important: Inline editing is not possible/useful
when using the <cms:parse> tag!
25
The <cms:parse> tag
26. ● Two classes are needed:
● Parser, extending the
A_CmsConfiguredHtmlParser
Parser defines the custom Html Visitor
● Html Visitor, extending the CmsHtmlParser for
manipulating the HTML Code
● Little example: Add class to all links to
OpenCms website
26
The <cms:parse> tag
31. ● The Problem:
● Website is running at www.mysite.com
● OpenCms is configured that no
„/opencms/opencms/ is shown in URL
● Data stored at www.mysite.com/bigmedia should
not be stored in OpenCms
● BUT: OpenCms Linkmanager „grabs“
everything starting with www.mysite.com as
internal links
● LinkManager will show errors
31
Linkexcludes
32. ● The Solution: Linkexcludes!
● Defined in /system/shared/linkexcludes
● All paths entered are not processed by the
internal link check
32
Linkexcludes
33. ● A little configuration is required:
● In opencms-importexport.xml change
org.opencms.staticexport.CmsDefaultLinkSubstitutionHandler
to the advanced link substitution handler
org.opencms.staticexport.CmsAdvancedLinkSubstitutionHandler
33
Linkexcludes
35. OpenCms has a workflow?
Using the OpenCms Workflow35
36. ● What - OpenCms has a Workflow?
● Yes – at least some kind of…..build after customer
requirements four years ago
● What does it do?
● Editor users are not allowed to publish
● They can send publish requests for content to be
published
● Adminstrators are notified of those requests and
publish the content
● All is done via the publish dialog
36
Using the OpenCms Workflow
37. ● Configuration: Add the follwoing to the
opencms-system.xml
● All users of the defined
„workflowProjectManagerGroup“ will notified by
email
37
Using the OpenCms Workflow
38. ● Step 1:
● User tries to publish, but has not enough
permissions to do so
38
Using the OpenCms Workflow
39. ● Step 2:
● User switches to „release“, the publish dialog
behaves like during a „normal“ publication
39
Using the OpenCms Workflow
40. ● Step 3:
● Adminstrator receives email
40
Using the OpenCms Workflow
41. ● Step 4:
● By clicking on email or accessing the publish
dialog directly, the requested content can be
published
41
Using the OpenCms Workflow