cancel
Showing results for 
Search instead for 
Did you mean: 

Limiting content types in a specific folder

ganm
Champ in-the-making
Champ in-the-making
Hi,

I have a custom content type containing only metadata that inherits from base (as shown in Jeff Potts tutorial). Now I need a folder, that only can contain this custom content type. Further, there has to be no 'Add content' button, but only the 'Create Content' button. How can I implement this?

Regards
ganm
12 REPLIES 12

bwagner
Champ in-the-making
Champ in-the-making
I have the same issue. is there a way to limit the types shown in ContentTypewizard based on the space/folder?

hsohaib
Champ on-the-rise
Champ on-the-rise
there has to be no 'Add content' button, but only the 'Create Content' button. How can I implement this?

Create a new Spring/Managed bean like this one :


package ma.samples;

import org.alfresco.web.bean.NavigationBean;

/**
*
* @author Haltout Sohaib
*/
public class CustomSpaceBean {
   
    private NavigationBean navigationBean;

    /**
     * Get the value of navigationBean
     *
     * @return the value of navigationBean
     */
    public NavigationBean getNavigationBean() {
        return navigationBean;
    }

    /**
     * Set the value of navigationBean
     *
     * @param navigationBean new value of navigationBean
     */
    public void setNavigationBean(NavigationBean navigationBean) {
       
        this.navigationBean = navigationBean;
    }
   
    private boolean renderAddContent;

    /**
     * Method to determine weither to show the 'add content' action
     * or any other action by the space type.
     *
     */
    public boolean isRenderAddContent() {
        return !(navigationBean.getCurrentNode().getType().equals(MyContentModel.CUSTOM_SPACE_QNAME);
    }

    /**
     * Set the value of renderAddContent
     *
     * @param renderAddContent new value of renderAddContent
     */
    public void setRenderAddContent(boolean renderAddContent) {
        this.renderAddContent = renderAddContent;
    }



}

add the bean to your model-context.xml :


<bean id="customSpaceBean"
class="ma.samples.CustomSpaceBean">
<property name="navigationBean">
<ref bean="navigationBean" />
</property>
</bean>

edit your browse.jsp, find this line :
<r:actions id="acts_add_content" value="add_content_menu" context="#{NavigationBean.currentNode}" showLink="true" />

Change it to :
<r:actions id="acts_add_content" value="add_content_menu" context="#{NavigationBean.currentNode}" showLink="#{customSpaceBean.renderAddContent}" />

That should do it. If you want to hide more actions it will be the same.
There should be other easier solutions but for now you could try this one.

ganm
Champ in-the-making
Champ in-the-making
Hi hsohaib,

Thank you for your detailed response. I will try to implement this in the next days.

Since I'm new to Spring, does anybody know good resources (tutorials, how tos etc) for beginners?

Regards,
GANM

samira_a
Champ in-the-making
Champ in-the-making
hi i`m new on alfresco i have the same problem but first i dont know where should i create managed/spring bean,please explain more detail about this section
i`ll be so thankfull

azade
Champ in-the-making
Champ in-the-making
this code is for java project for example netbean environment

gandra
Champ in-the-making
Champ in-the-making
"Add content button" problem apparently has solution.
Any idea how to limit content type depending on the folder where you are ?

wesse
Champ in-the-making
Champ in-the-making
If you looking for doing this for a specific type of folder it is easy.
http://wiki.alfresco.com/wiki/Externalised_Client_Actions
and check the "Type Based Action Configuration" section…

I have the need for doing this based on a aspect of a folder, I still look in to it but it seems that I need to extend both the BrowserBean and the brows.jsp file to achieve that.

gandra
Champ in-the-making
Champ in-the-making
Thans Wesse ,
but all my folder will be of the same type.

Is there any way to implement custom evaluator for Content Wizards
in a such way that according to the some folder/space properties(name, path, etc …)
choose what types to present in a list box on alfresco explorer when creating new contet?

Indeed I am looking to any solution for the next problem:

I have space called myspace. In that space I have3 more spaces: marketing, operations and hr.
In hr space
I have 2 spaces: legal and CV.

I have custom content types:
1. MyCo Document
2. Marketing Document
3. Operation Document
4. Legal Document
5. CV Document

When I am in the myspace and I want to create new content I want in combo box only to appear
    - MyCo Document
   
When I am in the myspace/marketing and I want to create new content I want in combo box only to appear:
    - MyCo Document
    - Marketing Document
   
When I am in the myspace/operations and I want to create new content I want in combo box only to appear:
    - MyCo Document
    - Operation Document

When I am in the myspace/hr and I want to create new content I want in combo box only to appear:
    - MyCo Document
    - Legal Document
    - CV Document
   
When I am in the myspace/hr/legal and I want to create new content I want in combo box only to appear:
    - MyCo Document
    - Legal Document
   
When I am in the myspace/hr/cv and I want to create new content I want in combo box only to appear:
    - MyCo Document
    - CV Document
   

   
I am looking forward any solution to achieve this … custom evaluator, customization of the content wizard, jsf gui customization …

wesse
Champ in-the-making
Champ in-the-making
Create an extention to CreateContentWizard set up that as the CoreateContentWizard and
override  the  public List<SelectItem> getObjectTypes() of ( CreateContentWizard->BaseWizardBean )

List<SelectItem> getObjectTypes() {

  List<SelectItem> objTypes = super.getObjectTypes();

  // do your filtering
  String nodeId = this.navigator.getCurrentNodeId();
  containerNodeRef = new NodeRef(Repository.getStoreRef(), nodeId);
  QName cName = getNodeService().getType(containerNodeRef);
  if ( getDictionaryService().isSubClass(cName, yourType) )
  else
  …
return objTypes;

}