After I reach the point where I think that my topics covering Liferay are finally done I encounter another task at work which I should solve.
Now it is the filtering of file names in the CKEditor file browser. This goes hand in hand with my previous article where I introduced an ext-plugin which can be used to sort files by their modification date.
The current extension is for those users who do not want to use an ext plugin for sorting by file modification date but want to filter by name.
I thought my adventures in Liferay would end at a hook and CKEditor, however I had to do some display of JournalArticles. And again, this was not an easy thing.
But I have found a solution. To get a Liferay JournalArticle’s content as XML, you can call
However this returns you the content in XML — and this is a bit hard to display. The suggested solution is to use JournalContentUtil provided by Liferay. It has a method getContent where you set the right variables you get your content — and only the content.
String content = JournalContentUtil.getContent(groupId, articleId, templateId, themeDisplay.getLocale().toString(), themeDisplay);
I won’t go into detail which parameters to set and how to get them. There are some questions around on the internet (at the Liferay Forum too) where you can take a look at and get some information.
However this is not working as you might expect. If you have content in only one language: go along and use the suggested method (and look for information on the internet).
If you have translations in other languages, then it is not working. You can add a language attribute but it does not help either: you get the content in the main language back (or the language of the user logged in) — and it is a problem if you want to display the contents in another language.
I’ve already written about extending Liferay’s CKEditor with custom Liferay Hooks to implement required functionality.
Today I’ll continue this article with another UseCase where I improved the sorting of the displayed files in the file browser window.
I started to create this article because of this Stack Overflow question.
In this article I’ll show you how to add this custom functionality to CKEditor, one of the usable editors in Liferay.