0

I wonder if its possible in any way to change the default view-renderer in the document-library of share based on the type of folder the user enters.

The default view overall seems to be set in the constructor of documentlist.js and the option "viewRendererName". How can I change this based on folder type?

In addition to Tahirs links below I would like to add the following blogpost as well which gives a good overview on how this can be done using a module evaluator:

http://experiencewithalfresco.blogspot.dk/2012/06/type-subcomponent-evaluator.html

billerby
  • 1,977
  • 12
  • 22

3 Answers3

3

Well, after some digging around we found this feature (undocumented?). In applicationModel.xml there is this aspect named app:defaultViewConfig, apply that to your type and set the property app:defaultViewId to the id of the view you want as default and you are all done (as it seems after our first tests)

billerby
  • 1,977
  • 12
  • 22
1

If you take a look at the Extension Modules explained in a lot of Dave Draper's blog, for example here.

You'll notice that you can add share evaluators on different parts in Alfresco. So you could write an evaluator which checks on the node what the type of the folder is and show a custom documentlist.get.html.ftl with another viewRendererName.

An example of a share evaluator:

public boolean evaluate(JSONObject jsonObject) {

        try {

            JSONObject node = (JSONObject) jsonObject.get("node");
            // Do things with the node

            return <true/false>;

        } catch (Exception e) {

            logger.error(e.getMessage(), e);
            return false;
        }
    }
Tahir Malik
  • 6,623
  • 15
  • 22
  • That code looks like the evaluators I use in share to hide/show certain actions. I thought those could not be used as module evaluators? The evaluate method you supplied is not present in the ```org.springframework.extensions.surf.extensibility.ExtensionModuleEvaluator``` – billerby Mar 31 '14 at 11:40
  • Sorry I linked the wrong example link, the link should be the following: http://blogs.alfresco.com/wp/developer/2011/07/29/sub-component-evaluations/ – Tahir Malik Mar 31 '14 at 12:14
  • will this solution work in Alfresco 5.0.2 version? If yes, can anybody help how to show a custom documentlist.get.html.ftl with another viewRendererName as mentioned above? – Vishal Zanzrukia Aug 28 '16 at 13:53
0

How to change default view for particular folder or site?

We need to set "defaultViewId" as viewname(simple) which is property of "defaultViewConfig" aspect and need to add that aspect in relevant folder.

Ex.

Map<QName, Serializable> viewProp = new HashMap<QName, Serializable>();
viewProp.put(ApplicationModel.PROP_DEFAULT_VIEW_ID, "simple");
nodeService.addAspect(folderNodeRef, ApplicationModel.ASPECT_DEFAULT_VIEW_CONFIG, viewProp);

As per requirement , we need to write logic which can be in java or javascript.

Sanjay
  • 2,481
  • 1
  • 13
  • 28