To create your custom content model we need following files :
- Model file ( which is our own new file with custom metadata)
- Context file (which is useful to pointing our custom model file)
- web-client-config-custom.xml entry (which visibles our metadata in webclient)
In our case we have following 3 sample file to demonstrate this custom model.
- zModel.xml
- custom-model-context.xml
- web-client-config-custom.xml
zModel.xml
----------------
<?xml version="1.0" encoding="UTF-8"?> <!-- Custom Content Model --> <!-- types and aspects added here will automatically be registered --> <model name="z:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0"> <!-- Optional meta-data about the model --> <description>Custom Content Model</description> <author>XYZ</author> <version>1.0</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"/> </imports> <!-- Introduction of new namespaces defined by this model --> <!-- NOTE: The following namespace custom.model should be changed to reflect your own namespace --> <namespaces> <namespace uri="custom.model" prefix="z"/> </namespaces> <types> <type name="z:employee"> <title>EmployeeType</title> <parent>cm:content</parent> <properties> <property name="z:empID"> <title>Employee ID</title> <description>Employee ID</description> <type>d:text</type> <mandatory>true</mandatory> </property> <property name="z:empCity"> <title>City</title> <description>City</description> <type>d:text</type> <mandatory>false</mandatory> </property> <property name="z:joinDate"> <title>Join Date</title> <description>Employee Join Date</description> <type>d:date</type> <mandatory>true</mandatory> </property> </properties> </type> </types> </model>
custom-model-context.xml
------------------------------------
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <beans> <!-- Registration of new models --> <bean id="z.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap"> <property name="models"> <list> <value>alfresco/extension/zModel.xml</value> </list> </property> </bean> </beans>
web-client-config-custom.xml
-------------------------------------
<alfresco-config> <config evaluator="string-compare" condition="Content Wizards"> <content-types> <type name="z:employee" /> </content-types> </config> <config evaluator="node-type" condition="z:employee"> <property-sheet> <show-property name="z:empID" /> <show-property name="z:empCity" /> <show-property name="z:joinDate" /> </property-sheet> </config> </alfresco-config>
Please keep these 3 files in the following location :
<alf_home>\tomcat\shared\classes\alfresco\extension
Restart alfresco server.
In the web-client while uploading any content you will get new type like below :
and after content uploaded we have 3 new property visible
This is sample demonstration about custom model.
Thanks for the demo. I am just started learning Alfresco and I am fresh to these concepts. Can you please explain how the three properties EmpId, City and Join Date appear as the doc property. I don;t see any box above where those properties are inputted for the document. Thanks in advance
ReplyDeleteRajan