Sep 25, 2007

Alfresco : Content Model

Content is typically almost anything that you want store and retrieve. Its like a generic Object.
Like an object, Content also has attributes and can have behavior associated with it.
You can define your own Content (typically called Content Types) in Alfresco. Most of which is done via XML.
Any kind of customization in Alfresco should be done and kept in the tomcat\shared\classes\alfresco\extension folder (extensions). When Alfresco starts up, the .XML and .properties configuration is first looked up and picked up in webapps\alfresco\WEB-INF\classes\alfresco folder (WEB-INF) and then from the extensions folder. If the same property exists in both then the value in the extensions folder will take precedence.
Let's see an example of defining our own Custom Content Type. Following are the steps.
  1. Lets first define the object (content). In my case, I want to define a License object, having FirstName, LastName, License number, State and Information. Since this is a custom content type (a non-default with Alfresco installations), it needs to be defined in the extensions folder.
  2. The extensions folder will have a file called customModel.xml. In this file replace the following lines (if present)
    <!-- Introduction of new namespaces defined by this model -->
    <!-- NOTE: The following namespace custom.model should be changed to reflect your own namespace -->
    <namespace uri="custom.model" prefix="custom">

    with the following lines.

    <!-- Introduction of new namespaces defined by this model -->
    <!-- NOTE: The following namespace custom.model should be changed to reflect your own namespace -->
    <namespace uri="custom.model" prefix="ccs"/>

    <type name="ccs:license">
    <!-- <parent>cm:content</parent> -->
    <property name="ccs:fname">
    <title>First Name</title>
    <property name="ccs:lname">
    <title>Last Name</title>
    <property name="ccs:st">
    <property name="ccs:info">
    <title>License Number</title>

    This establishes the definition of a new content type called License, in the namespace identified as ccs. Note how the datatype of the member attributes are defined.
  3. Now we will have tell Alfresco to pick up this definition while booting up and make it available in it's content repository. For this we will have to edit another XML file in the extensions folder called custom-model-context.xml.sample. Note, we will have to rename this file and take out the last .sample out of it's name so that Alfresco does read from this file while booting up (yah, modify a file so that another file gets picked up and then make sure the first file is itself picked up. Even though it seems to be but it isn't a redundant step, its actually pretty well structured.)
  4. No code needs to be changed in the above file, as by default it picks up customModel.xml. Here you will see, that by adding additional lines in the list item, we can configure more customized models in different XML files (for the sake of readability and classification).
  5. Now that Alfresco has picked up the files and the model, It needs to know 'where' and 'how' it is supposed to display the Content. Whether it will come in a dropdown while adding files? Whether the attributes will be shown to the user to be filled in as a textbox? and so on. For this we will modify yet another .XML file in the extensions folder called, web-client-config-custom.xml. This file defines most of the UI elements needed by Alfresco. Put the following before the </alfresco-config> tag.
    <!-- **************************** AV Config Start ************************-->
    <!-- Make sure that the properties for license are available -->
    <config evaluator="node-type" condition="ccs:license">
    <show-property name="mimetype" display-label-id="content_type" component-generator="MimeTypeSelectorGenerator"/>
    <show-property name="size" display-label-id="size" converter="org.alfresco.faces.ByteSizeConverter" show-in-edit-mode="false"/>
    <show-property name="ccs:fname"/>
    <show-property name="ccs:lname"/>
    <show-property name="ccs:info"/>

    <!-- List ccs:license when creating new content -->
    <config evaluator="string-compare" condition="Content Wizards">
    <type name="ccs:license"/>

    <!-- Lists the custom aspect in business rules Action wizard -->
    <config evaluator="string-compare" condition="Action Wizards">
    <type name="ccs:license"/>

    As you can see, we configure 3 components of the UI.
    The first is the node-type, which lets Alfresco know that whenever it displays the ContentType License, it has to display 3 attributes, the Firstname, Lastname and Info, by default it will pick up the <title> in the contentModel.xml
    The Second is the Content Wizards dropdown menu and the third is for Action Wizards dropdown.
  6. When you upload content you will now notice the Content Wizard showing an additional Content Type in the drop down.

  7. And on the next screen, you should be able to see the content properties (attributes).

  8. That's it...enjoy your modeling.
Unknown said...

Thank you for describing this process. I had referred to some very informative articles, but still was not successful in creating a new model. Your steps helped me resolve the issue.

nys said...


Thanks for the information.I tried exactly what u have said ..but still its not showing up in the web client Add content. What could be the reason


jordisan said...

In step 2 (customModel.xml) I think you have to change also the prefix in model name from

<model name="custom:customModel"...


<model name="ccs:customModel"...

Content Consultant said...

I am Still getting
An Error :

Namespace prefix ccswfcredential is not mapped to a namespace URI

Mihir Mistry said...

Hi It's a great article for describing Content Model in alfresco. If you can explain Association,Aspects in content model, means why we need it, How to decide where to use it. Thanks well in advance.

Victor Piousbox said...


maybe you need to specify it as ccs:credential
Also as RamSys said, custom:customModel needs to be replaced with css:customModel. That said, this article worked for me, thanks OP!

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search