You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Thomas Pii <th...@dbc.dk> on 2014/04/02 09:54:26 UTC

Velocity template examples and hardcoded contextPath

The current velocity template examples in the 4.6.1 distribution have a hard
coded context path for the solr web application:
#macro(url_root)/solr#end
in VM_global_library.vm hardcodes it to /solr

I would like to change this to determine the context path at run time, so
the templates do not require modifications if deployed to a different
context path.

Does anyone have any experience with this?

I have found LinkTool in Velocity which has the method getContextPath(), but
I am unsure if it can be used and how to use it if so.
I was thinking somethink like:
#macro(url_root)$link.contextPath#end

So far my attempts have failed and I am unsure how to access it and the
right syntax for it.

Whatever i put in the url_root macro just ends up as strings in the
generated HTML:
  
  <link rel="stylesheet" type="text/css"
href="$link.contextPath/my-index/admin/file?file=/velocity/main.css&contentType=text/css"/>
  <link rel="stylesheet"
href="$link.contextPath/my-index/admin/file?file=/velocity/jquery.autocomplete.css&contentType=text/css"
type="text/css" />
  

I appreciate any pointer you can give me.
Regards
Thomas



--
View this message in context: http://lucene.472066.n3.nabble.com/Velocity-template-examples-and-hardcoded-contextPath-tp4128545.html
Sent from the Solr - User mailing list archive at Nabble.com.