cancel
Showing results for 
Search instead for 
Did you mean: 

Freemarker templates URL's without space assignment

simon
Champ in-the-making
Champ in-the-making
Alf,

Small quick question this time. I have some templates that doesn't require a space to get the data. You can define templates that get the current space name but I have some templates that only use the companyhome.children for example.

I'll still parse these templates with a full URL like this one:
http://<server>/alfresco/template/workspace/SpacesStore/<spaceID>/workspace/SpacesStore/<templateID>
Point is… I don't really need the first 50% of this URL, I only need the template. If use the direct link the Freemarker code isn't parsed. Any way to use a shorter URL to the template without having to assign some space fist?

Why is this important? First of all, it ugly overhead and secondly… spaces may disappear and this could break my template which isn't even using that space.
2 REPLIES 2

kevinr
Star Contributor
Star Contributor
Small quick question this time. I have some templates that doesn't require a space to get the data. You can define templates that get the current space name but I have some templates that only use the companyhome.children for example.

I'll still parse these templates with a full URL like this one:
http://<server>/alfresco/template/workspace/SpacesStore/<spaceID>/workspace/SpacesStore/<templateID>
Point is… I don't really need the first 50% of this URL, I only need the template. If use the direct link the Freemarker code isn't parsed. Any way to use a shorter URL to the template without having to assign some space fist?

Why is this important? First of all, it ugly overhead and secondly… spaces may disappear and this could break my template which isn't even using that space.

This is true and bad design on my part. I should have put the template noderef as the first arguments, not the last as it forces you to put a context first whether you need it or not. The theory at the time was that the template servlet was mostly going to be used to show the "default" template for a document/space - so you would generally only specify the document/space and not always specify the template itself - which is why it comes later on the URL. However it has been shown that this is not the general case…

There is a neat way around the problem, which is to specify the template itself as the context, e.g.
http://<server>/alfresco/template/workspace/SpacesStore/<templateID>/workspace/SpacesStore/<templateID>
Which means you don't need any other noderefs in your hand, but the URL is still long and annoying.

For 1.4 we will be supporting "path" arguments for all servlets e.g you will be able to create URLs like this:
http://<server>/alfresco/template?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/mytemplate.ftl

Which will be very useful Smiley Happy

Thanks,

Kevin

simon
Champ in-the-making
Champ in-the-making
Thanks again Kevin. Your workaround seems like a nice way to solve the "when the node disappears" problem, I'll try this out.