cancel
Showing results for 
Search instead for 
Did you mean: 

FreeMarker issue : get all parents hierarchy

axis18
Champ in-the-making
Champ in-the-making
Hello everybody,

I'm a beginner in Alfresco and I have already got an issue : I would like to display a button in the documentLibrary, but only if the current space  has a parent (or grand parent, etc.) which has a specific aspect. I know how to check this point but I don't know how to get back the entire hierarchy over the current space. My main issue is that we can't use while loops in freeMarker, so I would like to put all of them in a list but I don't know how…
That's all, I'm sorry if this question has already been asked (or if it is stupid !), but I haven't found anything about it (neither in doc, forum nor freemarker doc). I use community 4.2 on centOS.

Thanks in advance.
1 REPLY 1

zladuric
Champ on-the-rise
Champ on-the-rise
Well, this may seem a bit hard to achieve if you're new to Alfresco. It may seem a lot, but actually, it's easier than that Smiley Happy
But here goes:
First, you don't need freemarker. You need client-side javascript. The document library is created by client side javascript. Check in your alfresco Share folder:
/share/components/document-library
. There are scripts that do the actual loading and displaying of document library.
Second: this is a dynamic process. So, when you click on a folder, you will see a #path in the URL. If you also open up a network tab in the browser console (say Chrome -> rightclick -> Inspect element, then click Network), you will see that each time you click a folder, a request to the backend is made.
This is your first point. Identify which backend (/alfresco) webscript is called (don't know by heart, I think it is GET /api/node/… something). Then modify that webscript so it also includes your information about the specific aspect in parents.
So now you have extra info, but you also need to show this info.
For that, go back to client-side javascript file, and look for where it draws a datatable with results. You can check and add the special button there. (Check YUI 2 DataTable over at http://developer.yahoo.com/yui/datatable/ for details).

It's a rough outline of what needs to be done, but I hope it helps. Ask more if you get stuck.