I'm crating a web script in alfresco where I implement a kind of custom search on my document, after the data are entered on the form the documents are listed on the page.
For each documents I would like to print a link to the parent folder on the ftl template as it appens on the standard search.
You can get the parent node directly on the script node. The parent node has a "url" property but I don't think it matches the format you described. However there is a "displayPath" property that makes it possible to build your "url". You should take a look at the source code of the standard search results page to see how Alfresco build this kind of url.
I think you should take a look to the source code of "search.get" Share webscript. You'll find the source code in the share.war file (../WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/search/search.get*).
I think that what you're looking for is located in search.js file (../components/search). That's the javascript code related to the search.get webscript. See _getBrowseUrlForRecord method.