We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31559
    • 20 Posts
    I currently have a sidebar chunk in a template that displays an image. I want to vary the image source based on the document ID. I’m sure there is a simple way of doing this, but lack the knowledge to do it. I’m assuming this needs to be done through some kind of php if/else statement and something to do with the documentObject[’id’] but can’t figure out the syntax.

    Ultimately I think I want to end with the src for the image being src=some snippet/variable

    It would be handy for the API to have some simple examples of usage. I’m caught between asking stupid questions and not quite knowing a good source to up my knowledge on the API.
      • 26435
      • 1,193 Posts
      ScottyDelicious Reply #2, 20 years ago
      I think a template variable [*tv*] would be a good fit for this situation.
      you could do <img src="[*nameOfTV*]" alt ="" /> in the chunk (or directly in the site template),
      then create a new TV called nameOfTV (or whatever you want) as raw text and maybe even give it a default path to an image. on each document you will now be able to edit the path in the tv to a specific per page image.

      -sD-
        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
        All of the above... in no specific order.


        I send pointless little messages
        • 31559
        • 20 Posts
        only when you actually see it written down do you realise the simplicity of it. I think I’d fundamentally misunderstood the TVs and how they were used. Thanks for your help, it was what I was looking for.