h1. How to create a site template in WCM


h2. Add a new template for portal 
* Open this file <TOMCAT-HOME>/portal/WEB-INF/conf/uiconf/portal/webui/portal/PortalTemplateConfigOption.groovy
Normally, it's look like this
{code}
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 ;
{code}

And you have to add some lines like this before return.
{code}
SelectItemCategory test = new SelectItemCategory("TestTemplate");
test.addSelectItemOption(new PortalTemplateConfigOption("Test Template", "test", "Test Template", "TestTemplate").addGroup("/platform/administrators"));
options.add(test);
{code}

h2. Add resource bundles for new template 
* Open <TOMCAT-HOME>/portal/WEB-INF/classes/locale/wcm/webui_en.xml (and other webui.xml files also), and add these
{code:xml}
<TestTemplate>
 <label>Test template</label>
</TestTemplate>
{code}

1 Update illustration image for new template

* Open <TOMCAT-HOME>/eXoWCMResources/skin/DefaultSkin/wcm-portal/Stylesheet.css to update the stylesheet

{code}
.UIItemSelector .ItemDetailList .TemplateContainer .TestTemplateImage {
 background:transparent url(background/testtemplate.png) no-repeat center;
 height: 235px;
 width: 296px;
 margin: 3px auto;
}
{code}

* *Note*: 
** The class name is the name of new template appends with "Image"
** Please don't forget to add new image into <TOMCAT-HOME>/eXoWCMResources/skin/DefaultSkin/wcm-portal/background/ folder

1 Update pages and portlet preferences 
* Put some xml files to <TOMCAT-HOME>/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

1 Update pre-defined contents data (like logo, footer, navigations, ...) 
* 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

1 Update pre-defined contents configuration
* Make a copy of file <TOMCAT-HOME>/portal/WEB-INF/conf/wcm/deployment/template-deployment-configuration.xml, and modify it
{code:xml}
<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>
{code}

* *Note*: \{portalName} will be replaces with the name of portal when a portal is created
