How to add custom attributes to content

I want to attach some custom attributes for e.g. weight (numeric) which uploading content using the DAM admin console. I also want to be able to fire a range query on this numeric field. From the 'Edit' section of the content, I could not find any way to add this custom field. Could you please suggest some way to do this? I may have to add multiple such attributes in future. Any help is really appreciated.

0 votes

1 answers



To add custom attributes you need to load your own “layouts” which contains your desired attributes. You can add as many fields as u want.

Create a file layout-contrib.xml file. You can define ur fields through widgets. In nuxeo, each field/attribute is defined through widget. Write your widget in layout-contrib.xml. For example,

    <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
    <layout name="My_layout">

            <template mode="any">/layouts/layout_default_template.xhtml


     <widget name="weight_widget" type="int">
                <label mode="any">Weight </label>
        _   <properties widgetMode="edit">
                <property name="required">true</property>



Define your own schema, for example layout_demo_schema and declare it in core_types-contrib.xml as below.

<schema name="layout_demo_schema" prefix="lds"
        src="schema/layout_demo_schema.xsd" />

You need to define int_field type in layout_demo_schema.

In ui-types-contrib.xml file define your custom document type and dont forget to declare the layout for document. Consider the below,

    <type id="Custom_file_type">
        <description />
        <layouts mode="any">

I got the solution like this. Hope you will find this helpful.

0 votes