Although you can deploy a layout template by itself, you can also bundle it with a theme. If you generated a layout template with the Layouts sub-generator from inside a generated theme project, the layout template is bundled with the theme automatically. If, however, you generated a layout template and want to bundle it with a theme afterwards, follow these steps to include the layout template with a theme:
-
Copy the layout template’s
liferay-layout-templates.xml
file to the theme’ssrc/WEB-INF/
folder. -
Create a
layouttpl/custom/my-layouttpl/
folder inside the theme’ssrc/
folder. -
Copy the layout template’s FreeMarker (.ftl) file, and thumbnail preview (.png) if it exist, over to the
layouttpl/custom/my-layouttpl/
folder. -
Copy the theme’s
liferay-theme.json
file into thesrc/layouttpl/custom/my-layouttpl/
folder and rename itliferay-plugin.json
. -
Open
liferay-plugin.json
, rename theLiferayTheme
entryLiferayPlugin
, and replace thepluginName
entry’s value with the name of the layout template. Below is an example configuration:
{
"LiferayPlugin": {
"deploymentStrategy": "LocalAppServer",
"appServerPath": "C:\\Users\\liferay\\opt\\Liferay\\bundles\\liferay-ce-portal-tomcat-7.2.0\\tomcat-9.0.10",
"deployPath": "C:\\Users\\liferay\\opt\\Liferay\\bundles\\liferay-ce-portal-tomcat-7.2.0\\tomcat-9.0.10\\deploy",
"url": "http://localhost:8080",
"appServerPathPlugin": "C:\\Users\\liferay\\opt\\Liferay\\bundles\\liferay-ce-portal-tomcat-7.2.0\\tomcat-9.0.10\\webapps\\my-layouttpl",
"deployed": false,
"pluginName": "my-layouttpl"
}
}
Now you know how to include layout templates with your Liferay DXP themes!