In this page we will see some "Tips and Tricks". We hope they will be useful for you!
“When building lists of content, it's a typical requirement to link from a condensed view of the content to a more detailed view. For example, in a list of news, only title, teaser and maybe a date and author are displayed. You click on a news to get to a page showing the complete news article. Similarly, events, products or any other type of resource/content may be shown in a list with links to a detailed view added” (form https://documentation.opencms.org)
But how we can state programmatically if a page is a detail page?
We can use the class CmsJspStandardContextBean and the class method “isDetailRequest”, as for the following example:
CmsJspStandardContextBean contextBean = CmsJspStandardContextBean.getInstance( request );
if (contextBean.isDetailRequest() ) {
some_action;
}
else{
other_action;
}
The method can be useful if the same page shows both the list and the detail content.
In this case, my purpose could be to show a given content by using the above method.
OpenCms uses the “HtmlWidget” widget to manage contents in HTML. The HTML editor is based on TinyMCE plugin.
In case you use the <i> tag, this tag will be replaced automatically by <em> tag, while the <b> tag will be replaced by <strong> tag.
For <i> tag this behaviour is annoying because the <i> tag is used in Bootstrap to display icons.
However you can use a workaround by modifying the “resources/editors/tinymce/jscripts/tinymce/tinymce.min.js” file; this is a file created on real file system when OpenCms is installed: you have to find the em/i string and delete it.
I know that the trick is a bit dirty (the best solution could be to generate a new custom module), but it's effective.
If you have to manage fonts having special extensions (for example ttf, eot, woff), you can see that all runs right in offline project, but they are not rendered correctly in online project. To render them correctly you have to modify OpenCms configuration files.
The first step is to modify opencms-vfs.xml, to add the mimetype needed, for example font-woff:
<mimetypes>
<mimetype extension=".ez" type="application/andrew-inset" />
...
<!-- New mimetype -->
<mimetype type="application/font-woff" extension=".woff"/>
<!-- end New mimetype -->
</mimetypes>
The secon file you have to modify is opencms-importexport.xml, as in the following example:
<defaultsuffixes>
<suffix key=".jpg" />
...
<!-- New suffix -->
<suffix key=".woff"/>
<!-- end New suffix -->
</defaultsuffixes>
In order to the new configuration works you have to restart your application server (usually Tomcat).