We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29979
    • 21 Posts
    Hello all,

    I was wondering if someone can point me in the right direction.

    What I would like to do is this create a snippet of some sort that will check for the current URL and then based on that URL change the banner within my web page.

    For example if i’m in the ABOUT section of my site... then the image that will be associated with that page will be a Book... or something like that.

    If i’m in the ORDER NOW section of my site the image associated with that page will be an image of a dollar or something along those lines.

    So what i’m hoping to get some help on is a script that will check for current URL then maybe pass a CSS class to a div within my webpage that will then pull in the correct image to display.

    Thanks,

      • 16183
      • 1,390 Posts
      I think I have seen a snippet in the forums that can do this...but can’t seem to recall its name...anyway, you can also do this easily with TVs. The image will be inserted as part of the content using the first method and as a background image using the second.

      First Method

      1. Create an image TV and associate it with your sites template(s), i.e. the templates your resources (documents) are using

      2. In your site’s template call the TV where you want it to appear, i.e. where your banner is

      So, something like:
      <img src="[*nameOfYourImgTV*]" />


      3. Then, when editing the document, say "About", just choose the image you want using the TV

      Second Method

      If you prefer to call the image as a background image you can instead create a text TV where you will write the name of the css class you want associated with the respective pages.

      so, something like:
      <div class="[*nameOfYourTextTV*]"></div>


      3. Then when editing the documents, enter the name of the class you want for that page. The rest of the magic is in your CSS.

      Hope this helps smiley

      cheers/k