We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37363
    • 3 Posts
    Hello ModX world,
    I have done some searches about how to have a different images for different pages that are based on the same template. I ran into an example using flash - which I tried but did not work (most likely my fault. I am new to ModX) - and another example that uses CSS to display the header as a background. This last solution would be perfect but the down part of it is that when you print a page the header background is not included printing only the content and menu (in my case). So, I am wondering if some cool ModX expert can give me a hand here and explain me how this can be achieve using TV's

    Thank you in advance

    This question has been answered by multiple community members. See the first response.

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Create an image-type TV and assign it to the relevant templates.

      In your template, put the TV tags where you would ordinarily put the URL to the image.

      <a href="[*imageTV*]" alt="[*pagetitle*]">


      Now, when you create or edit a resource, select the image for that page in its TV field.

      If you want sections of the site to use the same image, use @INHERIT as the default value when you create the TV, and set the desired image in the parent resource. All of its children in the Resource Tree will inherit that value.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
      • discuss.answer
        • 3749
        • 24,544 Posts
        Susan, doesn't an image TV create a full <img> tag, with it's own alt attribute (I never use them, so I could be wrong)?
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
        • discuss.answer
          • 37363
          • 3 Posts
          Thank you so Much Sottwell,

          - TV image ->created
          - Edit resource > insert the <img src="yourImage"/> into the Template Variable field.

          Thanks again, TV's are powerful !
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            You're still working too hard wink

            Use an Image type TV and upload/select the desired image from the popup image browser. You don't need to enter anything else in the TV field when you edit the resource. Put the <img...> tags in your template where you want the image to appear; just replace the URL of the image with the TV tags.

            If you want the TV to output the entire <img ... > tags, then when you create the TV choose an Image output widget. MODx will generate the whole <img ... > tags only if you use an image output widget, no output widget == raw output. Raw TV output is my preference since I like to see exactly what's going on in my templates. [ed. note: sottwell last edited this post 14 years, 9 months ago.]
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
            • discuss.answer
              • 37363
              • 3 Posts
              You are right, I first browse for the image - the results display only the path to the image. Then I thought to put the img tag inside the TV field ..... never thought to placed it into the template... yeaks, I shall stop review, too much excitement just makes me keep going smiley .... Thank you one more time!
              • discuss.answer
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Having the TV output the whole <img ... > tag might be useful if some pages won't have an image at all; you don't want empty image tags hanging around putting up broken image icons on your pages!
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org