How to create a site template in WCM
1 Add a new template for portal
- Open this file /portal/WEB-INF/conf/uiconf/portal/webui/portal/PortalTemplateConfigOption.groovy
Normally, it's look like this
import java.util.List;
import java.util.ArrayList;
import org.exoplatform.portal.webui.portal.PortalTemplateConfigOption ;
import org.exoplatform.webui.core.model.SelectItemCategory;
List options = new ArrayList();
SelectItemCategory acme = new SelectItemCategory("ACMESite");
acme.addSelectItemOption(new PortalTemplateConfigOption("ACME Site", "acme", "ACME Site", "ACMESite").addGroup("/platform/administrators"));
options.add(acme);
return options ;
And you have to add some lines like this before return.
SelectItemCategory test = new SelectItemCategory("TestTemplate");
test.addSelectItemOption(new PortalTemplateConfigOption("Test Template", "test", "Test Template", "TestTemplate").addGroup("/platform/administrators"));
options.add(test);
2 Add resource bundles for new template
- Open /portal/WEB-INF/classes/locale/wcm/webui_en.xml (and other webui.xml files also), and add these
<TestTemplate>
<label>Test template</label>
</TestTemplate>
3 Update illustration image for new template
- Open /eXoWCMResources/skin/DefaultSkin/wcm-portal/Stylesheet.css to update the stylesheet
.UIItemSelector .ItemDetailList .TemplateContainer .TestTemplateImage {
background:transparent url(background/testtemplate.png) no-repeat center;
height: 235px;
width: 296px;
margin: 3px auto;
}
- Note:
- The class name is the name of new template appends with "Image"
- Please don't forget to add new image into /eXoWCMResources/skin/DefaultSkin/wcm-portal/background/ folder
4 Update pages and portlet preferences
- Put some xml files to /portal/WEB-INF/conf/portal/portal/template/test/ folders
- navigation.xml
- pages.xml
- portal.xml
- portlet-preferences.xml
- Note: owner id in these files always is @owner@
- Hint: you can make a copy from acme template files and edit anything you want
- To create your own contents, you can do as follow:
- Run WCM
- Go to Site Explorer and create new Web contents
- Publish it by Manage publication feature
- Export it (with version history), and you will have some xml files
- Put them in portal/WEB-INF/conf/wcm/artifacts/site-resources/test-templates/ folder
6 Update pre-defined contents configuration
- Make a copy of file /portal/WEB-INF/conf/wcm/deployment/template-deployment-configuration.xml, and modify it
<external-component-plugins>
<target-component>org.exoplatform.services.wcm.portal.artifacts.CreatePortalArtifactsService</target-component>
<component-plugin>
<name>Initial webcontent artifact for each site</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.services.wcm.webcontent.InitialWebContentPlugin</type>
<description>This plugin deploy some initial webcontent as site artifact to site artifact folder of portal when a portal is created</description>
<init-params>
<object-param>
<name>Portal logo data</name>
<description>Deployment Descriptor</description>
<object type="org.exoplatform.services.deployment.DeploymentDescriptor">
<field name="target">
<object type="org.exoplatform.services.deployment.DeploymentDescriptor$Target">
<field name="repository"><string>repository</string></field>
<field name="workspace"><string>collaboration</string></field>
<field name="nodePath"><string>/sites content/live/{portalName}/web contents/site artifacts</string></field>
</object>
</field>
<field name="sourcePath"><string>war:/conf/wcm/artifacts/site-resources/test-templates/Logo.xml</string></field>
</object>
</object-param>
<object-param>
<name>Portal signin data</name>
<description>Deployment Descriptor</description>
<object type="org.exoplatform.services.deployment.DeploymentDescriptor">
<field name="target">
<object type="org.exoplatform.services.deployment.DeploymentDescriptor$Target">
<field name="repository"><string>repository</string></field>
<field name="workspace"><string>collaboration</string></field>
<field name="nodePath"><string>/sites content/live/{portalName}/web contents/site artifacts</string></field>
</object>
</field>
<field name="sourcePath"><string>war:/conf/wcm/artifacts/site-resources/test-templates/Signin.xml</string></field>
</object>
</object-param>
...
</init-params>
</component-plugin>
</external-component-plugins>
- Note: {portalName} will be replaces with the name of portal when a portal is created