Create Custom Alfreco Content Types Step by Step

alfresco_2

Create Custom Alfreco Content Types Step by Step

There are few out of the box content models are available which can be used to design the custom content types.

File Namespace
dictionaryModel.xml model/dictionary/1.0
systemModel.xml model/system/1.0system/registry/1.0system/modules/1.0
contentModel.xml model/content/1.0
bpmModel.xml model/bpm/1.0
forumModel.xml model/forum/1.0

All these models are placed in WEB-INF\classes\alfresco\model.

Create Sample Custom Model

Hope development environment and Alfresco 4.x already in place. We can use two approaches for building the alfresco custom application. One using the war file creation and other is amp creation. It depends on the requirement which is applicable for you.

For custom content model need to follow below steps

  • Create directory structure
  • Create a model file
  • Create custom model context file
  • Create property file for resource bundle
  • Create custom web-client-config
  • Build war or amp
  • Deploy in tomcat and Restart

Create Directory structure

I would suggest to follow the following the directory structure which is easy to maintain for large scale development.

Create a model file

Create content model file sampleContentModel.xml in /src/main/config/model.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="ss:contentmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
       <!-- Optional meta-data about the model -->
       <description>Sample Content Model</description>
       <author>Saket S</author>
       <version>1.1</version>
 
       <imports>
              <!-- Import Alfresco Dictionary Definitions -->
              <import uri="http://www.alfresco.org/model/dictionary/1.0"
                     prefix="d" />
              <!-- Import Alfresco Content Domain Model Definitions -->
              <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
              <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
       </imports>
 
       <namespaces>
              <namespace uri="http://www.saketsaraf.com/model/content/1.0"
                     prefix="ss" />
       </namespaces>
 
       <types>
              <type name="ss:sampleFolder">
                     <title>Sample Folder</title>
                     <parent>cm:folder</parent>
              </type>
              <type name="ss:sampleContent">
                     <title>Sample Content</title>
                     <parent>cm:content</parent>
                     <properties>
                           <property name="ss:name">
                                   <type>d:text</type>
                           </property>
                     </properties>
              </type>
       </types>
</model>

In above code

  • <parent> is a type of content which could be file or folder or custom.
  • <namespace> uri could be anything with proper format. Version plays very important role and it should be incremental for major changes.
Total Page Visits: 3258 - Today Page Visits: 26

One Response to “Create Custom Alfreco Content Types Step by Step

Leave a Reply