Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: programmatically create and render web content in liferay 7.2
Hi all. It's my understanding that in liferay 7.2 the journal api are deprecated, and that we should always create web content with a structure and a template. I found some examples on the net in how to achieve so, the thing i am missing is how to retrieve the content for page rendering, since all the examples i've seen so far make use of the journal api Also can you recommend me some good resource with examples for liferay 7.2 apithank you in advance
Hey Fabio,The journal API is deprecated? I would be surprised of that was a true statement. WCM, is one of the pillars of Liferay. Deprecating the Journal API would be a big problem for long time users. 7.2 did introduce a Headless API that you can use to access different things including the Journal API, perhaps that is what you are thinking of?
There is also further improvements to the Page Fragments which is also a form of WCM -- more in context and sometimes referred to as "unstructured" content management. Regardless, the journal feature is still critical and still active -- at least to my knowledge.
Rendering a content item can be done in a few ways. Assuming that you are not using a Web Content portlet and you are asking how to retrieve the markup using the journal API, there are a few methods on the JournalArticleLocalService that you can leverage, one of which is the JournalArticleLocalService#getArticleContent method.
As you mentioned, structures and templates are key for this to work. Structures can be looked up using the DDMStructureLocalService and templates using the DDMTemplateLocalService. Once you have the Article, Structure and Template, tehn you should have everything you need to generate the HTML which you can then do whatever you want with.
There is also further improvements to the Page Fragments which is also a form of WCM -- more in context and sometimes referred to as "unstructured" content management. Regardless, the journal feature is still critical and still active -- at least to my knowledge.
Rendering a content item can be done in a few ways. Assuming that you are not using a Web Content portlet and you are asking how to retrieve the markup using the journal API, there are a few methods on the JournalArticleLocalService that you can leverage, one of which is the JournalArticleLocalService#getArticleContent method.
As you mentioned, structures and templates are key for this to work. Structures can be looked up using the DDMStructureLocalService and templates using the DDMTemplateLocalService. Once you have the Article, Structure and Template, tehn you should have everything you need to generate the HTML which you can then do whatever you want with.