cancel
Showing results for 
Search instead for 
Did you mean: 

create document from template grouping

we0038
Champ in-the-making
Champ in-the-making
hi, basically I can create new document from template, which I added to "Repository > Node Templates"
is it possible to make groups (folders) within the node templates so when creating "new document from templates" template documents shown as groups for easier navigation?
I tried to group documents in folders inside "Node Templates" but they never show up, must be placed directly on parent folder.
1 ACCEPTED ANSWER

steven_okennedy
Star Contributor
Star Contributor
Hi Johnny_K,

In Alfresco 5.1 a lot of the repository web scripts that are specifically for use by Share have been moved into their own jar file, called alfresco-share-services-5.1.XXX.jar so this is where you'll find the node-templates.get web script (e.g. \WEB-INF\lib\alfresco-share-services-5.1.e.jar\alfresco\templates\webscripts\org\alfresco\slingshot\documentlibrary\node-templates.get.js).

Alfresco provides a couple of ways to extend the controller of a webscript, either adding logic after the base controller executes but before it sends the model to the template engine, or by overriding the controller completely and executing new logic instead of the base file.  In this you want to do the latter, since there's no point executing the base query and then executing the modified one. 

To do this. copy the controller (node-templates-get.js) out of the jar and deploy it into a folder at the path /alfresco/extension/templates/webscripts/org/alfresco/slingshot/documentlibrary/.  You then make your logic changes as outlined above and once you restart/refresh your webscripts the screen will show templates from any subfolder of the node_templates folder

As to your other question, yes it's possible to do this but will require a lot more customisation.  You'll need to do the visual customisations to change what Share displays (as well as the client side behavioural logic to show children/sub folders in submenus).  You'll also likely need to put in new repository webscripts to look for templates in your custom folders - the out of the box one only looks in node_templates.  So it's a lot more work but is possible

Regards

Steven

View answer in original post

5 REPLIES 5

steven_okennedy
Star Contributor
Star Contributor
Hi,

One of my frustrations with the whole templating thing!  So there are two things, one easy to change, the other probably easy but more work.

The component that looks for templates to finds them by calling the node-template.get webscript.  This is just doing a simple search and returning the results.


search.selectNodes('/app:company_home/app:dictionary/app:node_templates/*[subtypeOf("cm:content")]');


The problem is that this search is just looking at the <em>immediate</em> children of the node_templates folder.  So it will ignore any documents in subfolders.  This should be quite easy to fix I think, with something like


search.selectNodes('/app:company_home/app:dictionary/app:node_templates//*[subtypeOf("cm:content")]');


The two slashes at the end tell the search to look for any descendents, not just direct children.  It would be very easy to put in a custom override for this webscript which modifies the search slightly as above.

The other issue is that, even with the above change, the results will still be shown as a flat list, regardless of what source subdfolder they are in.  Can be problematic/confusing with large numbers of templates and/or templates that share the same name.  This is more work to fix as you would need to do the UI changes, but also need to change the information being sent back by node-template.get to include the path information.  But shouldn't be massively complex.

The first change especially is very useful as you can apply permissions at a subfolder level inside node_templates allowing you to easily group/show/hide templates together without having to deal with document level permissions on each and every template.

Regards

Steven

Steven where  ican finde node-template.get. Try find in alfresco-remote-api-5.1.g.jar but there only quadds-item.get.js
where
// Gets all the QuADDS…
   var QuADDS = search.selectNodes('/app:company_home/app:dictionary/cm:QuADDS/*[subtypeOf("cm:folder")]');


I try make changes as you say? but nothing Smiley Sad

Alfresco vrsion 5.1

And another question
can i make some folders like Node Tmplate and add menu in action menu like on picture.

steven_okennedy
Star Contributor
Star Contributor
Hi Johnny_K,

In Alfresco 5.1 a lot of the repository web scripts that are specifically for use by Share have been moved into their own jar file, called alfresco-share-services-5.1.XXX.jar so this is where you'll find the node-templates.get web script (e.g. \WEB-INF\lib\alfresco-share-services-5.1.e.jar\alfresco\templates\webscripts\org\alfresco\slingshot\documentlibrary\node-templates.get.js).

Alfresco provides a couple of ways to extend the controller of a webscript, either adding logic after the base controller executes but before it sends the model to the template engine, or by overriding the controller completely and executing new logic instead of the base file.  In this you want to do the latter, since there's no point executing the base query and then executing the modified one. 

To do this. copy the controller (node-templates-get.js) out of the jar and deploy it into a folder at the path /alfresco/extension/templates/webscripts/org/alfresco/slingshot/documentlibrary/.  You then make your logic changes as outlined above and once you restart/refresh your webscripts the screen will show templates from any subfolder of the node_templates folder

As to your other question, yes it's possible to do this but will require a lot more customisation.  You'll need to do the visual customisations to change what Share displays (as well as the client side behavioural logic to show children/sub folders in submenus).  You'll also likely need to put in new repository webscripts to look for templates in your custom folders - the out of the box one only looks in node_templates.  So it's a lot more work but is possible

Regards

Steven

Thank you for your answer Steven, i found file Smiley Happy
i skip the second question , I thought it was a lot easier than you speak.Smiley Sad

johnny_k
Confirmed Champ
Confirmed Champ
I make all with node-template.get.js and that's not what I wanted
Found another way for answer on my second question. Try make this hack: 
https://heshawa.wordpress.com/alfresco-create-from-template-menu-arrange-with-sub-menues/