In this workshop, Georg demonstrates two important new features in OpenCms 9.5.
In the first part of this workshop, Georg shows how to use the new PDF features in 9.5. He explains how to create a nicely formatted PDF document from a XML content and how this PDF view can easily be attached to an existing detail page. He also shows how image preview thumbnails can be created automatically for uploaded PDF documents.
The second part introduces several new options of the form based XML content editor. These include the possibility to synchronize content between languages, to manage the visibility of content fields and to create dependencies between widgets and other input fields. Georg shows use cases for these new options, explain the required configuration in the XML schema files and provide pointers to the API for advanced implementations.
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
OpenCms Days 2014 - OpenCms content editor and pdf extensions
1. Workshop track
Content editor and PDF
extensions in 9.5
Georg Westenberger, Alkacon Software
27.11.2014
2. ● PDF extensions
● Generating PDFs from XML contents
● Generating thumbnails for PDFs
● Content editor extensions
● Locale synchronization
● Visibility handlers
● Change handlers
2
Overview
3. ● Generate PDFs from XML contents
● Write a JSP to generate XHTML which is then
converted to PDF using the flying-saucer library
● See code.google.com/p/flying-saucer/ for more
info on the library.
● PDFs are not stored in VFS, but generated on
the fly when a special PDF link is used
3
PDF Generation
4. Demo Demo
● Live Demo
4
PDF Generation
Demo
Demo
デモ
5. ● Step 1: Write a JSP to generate XHTML from
your XML content
● Step 2: Generate a PDF link with the
<cms:pdf> tag
● <cms:pdf
format='/system/modules/com.alkacon.bootstrap.formatters/pages/blog
-pdf.jsp'
content='${content.filename}' locale='en'/>"
5
PDF Generation – how to use
6. ● Generate thumbnails for PDFs in various formats
● <cms:pdfthumbnail format=„png“ file=„/my-document.
pdf“ width=„50“ />
● format: format for the thumbnails, use ‚png‘ or ‚jpg‘
● file: the path of the PDF for which to generate the
thumbnail
● width / height: At least one of these need to be
set, determines dimensions of thumbnail
● PDF thumbnails are cached on the server file
system
6
PDF thumbnails
7. Demo Demo
● Live Demo
7
PDF thumbnails
Demo
Demo
デモ
8. ● These only work with the XML content editor
introduced in OpenCms 8.5, not with the older
XML content editor or any other way of editing
XML contents
● Example: Type bs-image in the demo
8
Notes on the content editor
enhancements
9. ● Sometimes, no localization is needed for some
values in an XML content
● For example: IDs (product ID,…), images,
configuration data
● Make selected fields locale-independent
● For any change made in the editor, the field
value is updated in all other locales
9
Locale synchronization
12. ● Hide content fields from the user dynamically
● Visibility is determined by custom Java class
● Example: hide cryptic status / configuration
values from normal users, restrict them to
admins.
12
Field visibility handlers
13. Demo Demo
● Live Demo
13
Field visibility handlers
Demo
Demo
デモ
14. ● Configure in XSD schema:
<visibilities>
<visibility
element="GalleryTitle"
params="ROLE.GALLERY_EDITOR" />
<visibility
element=“OtherField"
class=“my.custom.VisibilityHandler”
params=“parameters for my custom class" />
</visibilities>
● element: The field being checked for visibility
● class: The Java class responsible for deciding whether the field is
visible
● params: Configuration string passed to the Java class
14
Field visibility handlers
16. ● Basic idea: Automatically update other fields
when a given field is changed
● Example: Updating a content field from a
property of a linked image
16
Dynamic field handlers
17. <editorchangehandlers>
<editorchangehandler
class="org.opencms.ade.contenteditor.CmsEditorChang
eHandlerProperty"
scope="Image"
configuration="Copyright|../Copyright" />
</editorchangehandlers>
● class : Custom Java class to process changes
● scope : Path of the field which is watched for changes
● configuration : Configuration string passed to the change handler class
17
Dynamic field handlers
18. ● Extend
A_CmsXmlContentEditorChangeHandler and
implement these methods:
public CmsXmlContent handleChange(
CmsObject cms,
CmsXmlContent content,
Locale locale,
Collection<String> changedPaths)
public void setConfiguration(String configuration)
Note: The return value of handleChange is not used, modify the
CmsXmlContent parameter directly instead
18
Dynamic field handlers
19. ● Any Questions?
19
Any Questions?
Fragen?
Questions ?
質問¿Preguntas?
Questiones?
20. Thank you very much for your
attention!
Georg Westenberger
Alkacon Software GmbH
http://www.alkacon.com
http://www.opencms.org
20