cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Category Tree

alfsender
Champ in-the-making
Champ in-the-making
Hi All,

I am trying to get Alfresco Category Tree, in json format.

I need all category in only one webscript call, i.e. from Top level to bottom level.

I am not sure how to do that. I am able to get all categories using getCategoryService().getChildren(categoryRef, Mode.ALL, Depth.ANY).

But how to use this in ftl file to create a json object. provide your suggestion in this.

Thank you..
4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator
Hello,

why not put the result of your method call in the result model of the web script controller and access that in your template?

Regards
Axel

alfsender
Champ in-the-making
Champ in-the-making
Hi Axel

Thank you for your response, here problem is I can do what you said, i can put result of above method and access it in template.

But this method returns collection of ChildRefAssoc, so how we will come to know which category belongs to which category, I mean how we will create tree structure with that.

Main category-1
        category-11
        category-12
Main category-2
        category-21
              category-211
              category-212
              category-213
        category-22

for above tree structure, i want json response also in same tree structure, with each category id and its name.

regards,
Alfsender

afaust
Legendary Innovator
Legendary Innovator
Hello,

then you might use the classification service available in templates and FreeMarker macros to generate the tree structure fully in the FTL, without need of a controller. I.e. use getRootCategories to start and then descend by calling immediateSubCategories for each category node you process within a macro.

Regards
Axel

alfsender
Champ in-the-making
Champ in-the-making
Hi Axel,

I used the same approach, thank you for you valuable response,

regards,
alfsender