Unable to change document metadata display, based on document type in Document Library view

cancel
Showing results for 
Search instead for 
Did you mean: 
Established Member

Unable to change document metadata display, based on document type in Document Library view

Dear All,

I try to display different document properties in the document library view, based on the document type.

Modified the custom-slingshot-application-context.xml by adding an evaluator:

    <bean id="evaluator.doclib.action.isCRTFOLDER" parent="evaluator.doclib.action.nodeType">
        <property name="types">
            <list>
                <value>edlif:CRTFolder</value>
            </list>
        </property>
    </bean>

Where the <value> shows on of the custom content type. This was developed with 5.2 model manager

Then changed the share-config-custom.xml by:

<config evaluator="string-compare" condition="DocumentLibrary">  
    <metadata-templates>     
        <template id="CRTFolder">
        <evaluator>evaluator.doclib.action.isCRTFOLDER</evaluator>
                             
            <banner index="10" id="lockBanner" evaluator="evaluator.doclib.metadata.hasLockBanner">{lockBanner}</banner>
            <banner index="20" id="syncTransientError" evaluator="evaluator.doclib.metadata.hasSyncTransientErrorBanner">{syncTransientError}</banner>
            <banner index="30" id="syncFailed" evaluator="evaluator.doclib.metadata.hasSyncFailedBanner">{syncFailed}</banner>
        
            <line index="20" id="ContractInfo">{edlif_strCONTRACT edlif_strCONTRACT} {edlif_strCONTRACTOR edlif_strCONTRACTOR} </line>
            <line index="30" id="ProjectInfo">{edlif_lovPARK edlif_lovPARK} {edlif_lovLAND edlif_lovLAND} {edlif_lovCOMPLEX edlif_lovCOMPLEX} </line>
        
        </template>
    </metadata-templates>
</config>

I created a second evaluator and second definition. When deployed, Alfresco shows the properties defined for the above example, for both types.

What I would like to achieve is to show a different set of properties based on the content type.

Do you have any advices how to do this?

Regards,

Zsolt Putnoky

4 Replies
Advanced II

Re: Unable to change document metadata display, based on document type in Document Library view

Well, what you did seems right.

If you want a different set of properties for different types, all you need is to create a new template section inside the metadata-templates section using a different id, and a different evaluator.

The second evaluator should check for the second custom type you have defined, and that is all.

If you have tried something already, it would help us if you share the full configuration you created, both share-config-custom.xml and the xml file you created to define the evaluators.

Established Member

Re: Unable to change document metadata display, based on document type in Document Library view

Hi Douglas,

I have not done any evaluator XML as the only thing I need is a boolean TRUE if the folder type matching one of the custom type I defined. I only modified the custom-slingshot-application context with the code I showed earlier. Even though I am not sure that is right. Here is what I have in the custom-slingshot-application-context.xml file:

<bean id="evaluator.doclib.action.isGENFOLDER" parent="evaluator.doclib.action.nodeType">
        <property name="types">
            <list>
                <value>edlif:GENFolder</value>
            </list>
        </property>
    </bean>
        
    <bean id="evaluator.doclib.action.isCONFOLDER" parent="evaluator.doclib.action.nodeType">
        <property name="types">
            <list>
                <value>edlif:CONFolder</value>
            </list>
        </property>
    </bean>

Basically trying to check the custom type assigned to the different folders. One of them should be a Generic Folder with 6 custom properties, the second one is an extension of the Generic Folder with 2 additional properties.

Then added this into the share-config-custom.xml

<config evaluator="string-compare" condition="DocumentLibrary">  
    <metadata-templates>     
        <template id="GENFolder">
        
            <evaluator>evaluator.doclib.action.isGENFOLDER</evaluator>
                            
            <banner index="10" id="lockBanner" evaluator="evaluator.doclib.metadata.hasLockBanner">{lockBanner}</banner>
            <banner index="20" id="syncTransientError" evaluator="evaluator.doclib.metadata.hasSyncTransientErrorBanner">{syncTransientError}</banner>
            <banner index="30" id="syncFailed" evaluator="evaluator.doclib.metadata.hasSyncFailedBanner">{syncFailed}</banner>
        
            <line index="10" id="ContractInfo">{edlif_strCONTRACT edlif_strCONTRACT} {edlif_strCONTRACTOR edlif_strCONTRACTOR} {edlif_lovMETIER edlif_lovMETIER} </line>
        </template>
    </metadata-templates>
</config>

This should show 3 properties of the 6 of the generic folder - this is only done for testing the evaluator

<config evaluator="string-compare" condition="DocumentLibrary">  
    <metadata-templates>     
        <template id="CONFolder">
        <evaluator>evaluator.doclib.action.isCONFOLDER</evaluator>
                             
            <banner index="10" id="lockBanner" evaluator="evaluator.doclib.metadata.hasLockBanner">{lockBanner}</banner>
            <banner index="20" id="syncTransientError" evaluator="evaluator.doclib.metadata.hasSyncTransientErrorBanner">{syncTransientError}</banner>
            <banner index="30" id="syncFailed" evaluator="evaluator.doclib.metadata.hasSyncFailedBanner">{syncFailed}</banner>
        
            <line index="10" id="ContractInfo">{edlif_strCONTRACT edlif_strCONTRACT} {edlif_strCONTRACTOR edlif_strCONTRACTOR} </line>
            <line index="20" id="ProjectInfo">{edlif_lovPARK edlif_lovPARK} {edlif_lovLAND edlif_lovLAND} {edlif_lovCOMPLEX edlif_lovCOMPLEX} </line>
        
        </template>
    </metadata-templates>
</config>

this should show the additional 3 properties in case of a Contract folder.

Tried to check the idea you mentioned to create a new metadata template. Do you know a good helpfile showing what to create and where? I am kinda lost between all the XML files I am modifying.

thanks alot for your help,

Zsolt Putnoky

Advanced II

Re: Unable to change document metadata display, based on document type in Document Library view

Well, evaluator.doclib.action.isGENFOLDER and evaluator.doclib.action.isCONFOLDER are evaluators. That is exactly what you are doing in the xml file, defining new evaluators. Even though you should not be touching that xml file.

If you feel lost, then you should try to execute the following tutorial, which I believe will help you understand the concept and the required steps.

Adding new metadata templates to the Document Library | Alfresco Documentation 

Try it and come back to the community if you need help.

Established Member

Re: Unable to change document metadata display, based on document type in Document Library view

I guess I managed to make it work! However I do not understand the solution.

Created the two evaluators as shown above, modified the share-config-custom.xml as shown above and nothing happened. Then, and I do not know why, I created two JavaScript files to get the content type property value, format it and return it. When added these to the share-config-custom.xml:

<config evaluator="string-compare" condition="DocLibCustom">   
   <dependencies>   
       <js src="/js/DTMFolder.js" />  
   </dependencies>
</config>

<config evaluator="string-compare" condition="DocLibCustom">   
   <dependencies>   
       <js src="/js/CONFolder.js" />  
   </dependencies>
</config>

it started to work!

I do not use these scripts, they are there, working, but not used.

Also, I tried to put these into an 'extension' folder to avoid 'polluting' the ./share/js folder, but I had no luck with it.

Thanks alot for your help,

Zsolt Putnoky