1 Reply Latest reply on Oct 16, 2012 11:32 AM by nikhilgupta

    CSS dymanic url in .ftl

      Hey guys,

       

      We are getting ready to move to production and I would like to get rid of static references to the url. For example here is my current code:

       

      body {
        background: url(http://community.nana.com/theme/nana/img/bg_body.jpg) top center repeat-x #fff;
        padding: 0!important;
      }
      

       

       

      I am not to used to FTL and would like it to be something like this:

       

      body {
        background: url(http://' somevariable '/theme/nana/img/bg_body.jpg) top center repeat-x #fff;
        padding: 0!important;
      }
      
        • Re: CSS dymanic url in .ftl
          nikhilgupta

          Hi,

           

          In your theme create a sharedVariable.ftl file and add variable like:

           

          <#assign yourVar = "https://uat.nana.com" />
          

           

          Then include this ftl file where you need to access this variable like:

          <#include "/template/global/include/sharedVariables.ftl" />
          

           

          Then use the variable as required:

          url( '${yourVar}/theme/nana/img/bg_body.jpg')
          


          Hope this helps.


          P.S. if you are referring some thing in css you usually do it with reference like


          body { 

            background: url("/theme/nana/img/bg_body.jpg") top center repeat-x #fff

            padding: 0 !important

           

          This should work fine as well and it the the right way of doing it.

           

          - Nikhil