cancel
Showing results for 
Search instead for 
Did you mean: 

How to hide menu-options for specific content-type

ravichandanani
Champ in-the-making
Champ in-the-making
Hello,

I have a custom content type(bm:mybook) and its folder , I want to hide options like "Manage-Rule" for that particular content-type. can anyone please help me to configure that in share.



currently I have added following code in share-config-custom.xml, and I have created Java evaluator which checks if the content-type is bm:mybook and it returns true or false, based on the result false it excludes options Manage-Rule from the folder menu-list in share.


<actionGroups evaluator="node-type">

<actionGroup id="folder-browse">
   <action index="170" id="folder-manage-rules" >
      <evaluator>evaluator.doclib.action.excludeMyBook</evaluator>
   </action>
</actionGroup>

<actionGroups>


Evaluator code.


public class ExcludeMyBook extends BaseEvaluator{

   @Override
   public boolean evaluate(JSONObject jsonObject) {
      
      String nodeType = getNodeType(jsonObject); 
      
      if(nodeType.equalsIgnoreCase("bm:myBook")){
         return false;
      }
      return true;
   }
}



is there any other way of configuring this easily.

Thanks in advance
4 REPLIES 4

mitpatoliya
Star Collaborator
Star Collaborator
You need to add mapping in for your java class and evaluator in this file
custom-slingshot-application-context.xml


    <bean id="evaluator.doclib.action.excludeMyBook" class="com.abc.xyz.Evaluatorclassname" > </bean> 


Also make sure you package java class in jar and place it under share/WEB-INF/lib

Thanks for quick reply…!! I apologize for not writing all the configurations …I have already done all configurations and the menu-item hiding part is working perfectly …

The issue is there are some of the menu-item already hidden like following item,
<java>
<actionGroup id="folder-browse">
   <action index="360" id="document-cloud-sync" >
      <evaluator>evaluator.doclib.action.excludeMyBook</evaluator>
   </action>
</actionGroup>
</java>
now It will exlude for type bm:mybook, but it started to appear for other folders …
I am refering C:\Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\share-documentlibrary-config.xml for the menu-item list.


As per Alfresco documentation Actions can have multiple evaluators, if one of the evaluator for that action returns true the option will get displayed in menu-item.
And rightly my java code returns "true" for the types other than "bm:mybook". and it enables other types to forcefully have that option included in the menu-list. which is incorrect for me.

So I was looking for some quick and easy way around .

There needs to be some-way around .. Smiley Happy

mitpatoliya
Star Collaborator
Star Collaborator
could you post the link which you are referring for this?

mitpatoliya
Star Collaborator
Star Collaborator
I think this is the one you are looking for
evaluator.doclib.action.chainedMatchAll or evaluator.doclib.action.chainedMatchOne
They should run a list of evaluators as specified in
http://wiki.alfresco.com/wiki/Document_Library_Predefined_Evaluators.