Forums de discussion

Hierarchy of static HTML pages in a single web-content portlet

Adam Crowther, modifié il y a 10 années.

Hierarchy of static HTML pages in a single web-content portlet

New Member Publications: 11 Date d'inscription: 19/12/13 Publications récentes
Hi all,

I still consider myself a Liferay noob, so please forgive me if this is an obvious question. I'm using Liferay 6.2.

The requirement is very simple: A hierarchy of static HTML content to be displayed in a single portlet. Clicking on a link in one of these pages takes me to another page within the context of the same portlet, without affecting any of the other portlets on the site. Much like an Iframe or Proxy Portlet on to a third party site - but the content needs to be managed from whithin Liferay. (Additionally, some links in the content should link out of the portlet to other Pages in the Liferay Site. That seems to be pretty simple out of the box).

I have spent a long time researching this, looking for solutions. I tried to create a CMS template that loads a web-content-article dynamically, based on the value in a request parameter, but journalContentUtil.getContent(...) returns null:

#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#set ($journalContentUtil = $utilLocator.findUtil("com.liferay.portlet.journalcontent.util.JournalContentUtil"))
#set ($journalArticle = $journalArticleLocalService.getLatestArticleByUrlTitle($groupId, 'account', 0))

#if ($journalArticleLocalService)
    journalArticleLocalService is NOT null <br>
#else
    journalArticleLocalService is null <br>
#end
#if ($journalContentUtil)
    journalContentUtil is NOT null <br>
#else
    journalContentUtil is null <br>
#end
#if ($journalArticle)
    journalArticle is NOT null <br>
#else
    journalArticle is null <br>
#end
Group ID: $groupId <br>
Article ID: $journalArticle.getArticleId() <br>
View Mode: $viewMode <br>
Language ID: $locale.toString() <br>

#set ($content = $journalContentUtil.getContent($groupId, $journalArticle.getArticleId(), $viewMode, $locale.toString(), $xmlRequest))

#if ($content)
    $content <br>
#else
    content is null <br>
#end


returns this:
journalArticleLocalService is NOT null
journalContentUtil is NOT null
journalArticle is NOT null
Group ID: 10184
Article ID: 11133
View Mode: view
Language ID: en_US
content is null

Not really sure why, because $journalArticle.getContentByLocale() returns the correct content as a String, but it contains strange characters at the end.

Even if I do manage to get it loading the content correctly, I'm not sure how I would code the links so that a different article is loaded by the same portlet CMS template. At the moment I'm just loading a hard-coded article called "account" - this name would have to be read from a request parameter instead. But how to specify this request parameter in the link?

I'm not even sure I'm on the right track. It seems to me that there must be an easier way to achieve this very simple use case. What am I missing?

I'm stuck, so thanks in advance for any hints you can give.

Best Regards,

Adam
thumbnail
Vitor Manuel Lopes, modifié il y a 7 années.

RE: Hierarchy of static HTML pages in a single web-content portlet

New Member Publications: 17 Date d'inscription: 10/05/13 Publications récentes
Hi Adam...

Did you found a solution for this? I have exactly the same problem...
thumbnail
Fernando Fernandez, modifié il y a 7 années.

RE: Hierarchy of static HTML pages in a single web-content portlet

Expert Publications: 396 Date d'inscription: 22/08/07 Publications récentes
Hi,

My suggestion is to go for a custom portlet with AJAX data loading. That's the best way to load data without reloading the page.

HTH

Fernando