Fórum

Check of article/blog/wiki content

thumbnail
Gerhard Horatschek, modificado 9 Anos atrás.

Check of article/blog/wiki content

Junior Member Postagens: 86 Data de Entrada: 20/03/09 Postagens Recentes
Hi all,

A question regarding rendering the content of journal article, blog entries, wikis:
We need a check during the rendering of the content, which identifies links refering to the page where the content is rendered.
Such links should not be displayed as links (accesibility) ...
Is there any existing mechanism for checking the content against such links?

We are using Liferay 6.2 CE GA2.
Thank you for any information.
Best regards
Oliver Bayer, modificado 9 Anos atrás.

RE: Check of article/blog/wiki content

Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
Hi Gerhard,

afaik there isn't any solution for your requirement ootb but you should be able to implement it emoticon. I've had a similar requirement to mark all external links with an icon. Take a look at the "html / portlet / journal_content / view.jsp". There the rendered content is accessible via the "content" string variable. Now all you have to do is to parse this string. This can be done easily by using JSoup.

The following code snippet shows you how to use JSoup:
Document doc = Jsoup.parse(content);
doc.outputSettings().escapeMode(EscapeMode.xhtml);

// select all links of current web content
Elements allLinks = doc.select("a[href]");

// select al links with a given url
Elements allLinks = doc.select("a[href*=/web/guest/startpage]");

Now you can iterate over the list of all links and remove the link display e.g. by adding a css class.

HTH Oli