Question

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

Was it helpful?

Solution

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)

OTHER TIPS

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;
        }
    }

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top