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
How to create content programatically
Hi everyone,
I need to programatically create content (both pages based on template and web contents) on my Liferay 7.4 instance.
Basically I need to implement in Liferay a scheduled task which every night will fetch data from an external database and:
- Create a web content by filling the fields of the underlying structure
- Create a page using a specific template (it could be both a content page or a widget page)
Is this possible?
Can you suggest me the best way to do that and/or provide some hints about which Liferay API I should use?
Best regards,
Pietro
Hi ,
You can below API for creating Web Content and Page
//WebContent
_journalArticleLocalService.addArticle(externalReferenceCode, userId, groupId, folderId, titleMap, descriptionMap, content, ddmStructureKey, ddmTemplateKey, serviceContext);
//Pages
_layoutLocalService.addLayout(userId, groupId, privateLayout, parentLayoutId, name, title, description, type, hidden, friendlyURL, serviceContext)
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™