Search code examples
javaliferayliferay-7

Is there a way to retrieve the ADTs? It doesn't seem like using DDMTemplateLocalServiceUtil is the way to go


I'm trying to get all the adts of a website knowing it's groupid. However, it seems like the adts are mixed up with all the other templates of the site in the DDMTemplate table in the Database.


Solution

  • DDMTemplates are a general portal concept to manage templates for different types of portal assets (not only ADTs). DDMTemplateLocalService is a service to use to also list the ADTs for a certain asset type. You need to first fetch your ClassNameId for the desired asset type to render. For example:

    com.liferay.portal.kernel.service.ClassNameLocalService.getClassNameId(AssetEntry.class)

    for AssetPublisher entries (or BlogsEntry and so on - for all other types of interest). Having this id, you can query the ADTs of a site (groupId) using:

    com.liferay.dynamic.data.mapping.service.DDMTemplateLocalService.getTemplates(long groupId, long classNameId)

    Instead of using the *LocalServiceUtil static functions, you could also inject the service using the @Reference annotation. For example @Reference private DDMTemplateLocalService ddmTemplateService;.