cancel
Showing results for 
Search instead for 
Did you mean: 

How can I add action menu items for specific types?

stk137
Champ in-the-making
Champ in-the-making
Following the example, adding menu items will make them appear for all types.
How to I add them show they will only show up for certain types/subtypes?
Or just for certain paths?

Conversely is there a way to hide menu items for certain contexts?
For example, do not show the "start discussion" action on certain nodes.

thx
3 REPLIES 3

tfornoville
Champ in-the-making
Champ in-the-making
You can specify an evaluator to check various conditions

I have an action that I only want to show for nodes of type 'project'

In web-client-custom-config.xml:
   <config>      <actions>         <action id="process_project">            <evaluator>com.mediamine.rcd.core.upload.ProcessProjectEvaluator</evaluator>            <label>Process Project</label>            <image>/images/icons/workflow.gif</image>            <action-listener>#{UploadBean.processProject}</action-listener>                  </action>         <action-group id="space_browse_menu">            <action idref="process_project" />                     </action-group>               </actions>   </config>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

And the evaluator itself

package com.mediamine.rcd.core.upload;import javax.faces.context.FacesContext;import org.alfresco.service.cmr.repository.NodeService;import org.alfresco.web.action.ActionEvaluator;import org.alfresco.web.app.servlet.FacesHelper;import org.alfresco.web.bean.repository.Node;import com.mediamine.rcd.core.domain.RCDModel;public class ProcessProjectEvaluator implements ActionEvaluator{  public boolean evaluate(Node node)  {    FacesContext fc = FacesContext.getCurrentInstance();    NodeService nodeService = (NodeService)FacesHelper.getManagedBean(fc, "NodeService");    return nodeService.hasAspect(node.getNodeRef(), RCDModel.ASPECT_UPLOADED_PROJECT);  }}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope this helps.
I don't know the exact syntax for hiding menu items but I'm pretty sure you can do that.

gavinc
Champ in-the-making
Champ in-the-making
Yes you can hide actions easily, just use the following syntax in your action group config….


<action idref="id-of-the-action" hide="true" />‍

kevinr
Star Contributor
Star Contributor
In 2.1 you can configure action groups by node type:
http://wiki.alfresco.com/wiki/Externalised_Client_Actions#Type_Based_Action_Configuration

Thanks,

Kevin