cancel
Showing results for 
Search instead for 
Did you mean: 

Freemarker templates + URL parameters

simon
Champ in-the-making
Champ in-the-making
Hi,

I build a presentation template in Freemarker. It's actually only one method that accepts different parameters to launch some Lucene search query and returns the result as an HTML list. So far, so good.

The parameters are defined in the beginning of my template file so I need to build another template to change these parameters (don't want to display multiple lists on the same page). I'll probably need around 10 different searches so it would be better to get these paramters from the URL.

In this way I can build a seach query just by adding the right parameters like I would do in any web scripting language. Any thoughts?
4 REPLIES 4

kevinr
Star Contributor
Star Contributor
In Alfresco 1.3, any templates launched via the Template Content Servlet have a root Map object called "args" available to them that contains all URL arguments passed to the servlet.

Thanks,

Kevin

simon
Champ in-the-making
Champ in-the-making
Thanks Kevin, that is good news. Don't know how to get this to work though…
http://<server>/alfresco/template/workspace/SpacesStore/<spaceID>/workspace/SpacesStore/<templateID>?someparam=somevalue
doesn't seem to work.
<#if args?exists>
   Gentlemen, print your arguments please: ${args}
</#if>
This code doesn't print my "someparam" parameter, I'm triyng this in the 1.3 preview release. What should I do?

kevinr
Star Contributor
Star Contributor
Appologies, I should have said "1.3 final" - as it's not in the preview release.

Thanks,

Kevin

simon
Champ in-the-making
Champ in-the-making
OK Kevin, I'll have to wait for now and create like 20 redundant template files for the same result.  :shock: I wont keep you up much longer, you have better things to do (= finalizing 1.3).  😎