We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19507
    • 3 Posts
    hi i have a question

    I have 1 template
    and i want that every page loads his own image in the template using <img /> tags.
    like for home it need home.jpg
    for about about.jpg

    etc.

    can someone please tell me how ?
      • 4310
      • 2,310 Posts
      Quick way of doing it add this to your template :
      <img src="assets/images/[*description*].jpg" alt="[*description*]" />

      Then use the description TV in your documents for the name of the image i.e. home, portfolio etc. etc.
      Or create a new TV if you don’t want to use the description TV
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Or simply use [*alias*]. Thus,
        <img src="assets/images/[*alias*].jpg">

        would produce
        <img src="assets/images/home.jpg>
          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
          • 4971
          • 964 Posts
          Can I use this trick in my CSS?

          background: #fff url(assets/templates/site/images/[*alias*].jpg) no-repeat;
            Website: www.mercologia.com
            MODX Revo Tutorials:  www.modxperience.com

            MODX Professional Partner
            • 23363
            • 43 Posts
            I don’t think you can do that trick in the CSS, since the CSS is included and not parsed by MODx
              • 4310
              • 2,310 Posts
              pierun is correct but you could try adding the CSS as an inline style in your template e.g.
              <style type="text/css">
              #head {background: #fff url(assets/templates/site/images/[*alias*].jpg) no-repeat;}
              </style>
              

              I believe this would then get parsed and returned correctly, though I haven’t tested it.
                • 4971
                • 964 Posts
                Thanks a lot pierun and bunk...
                I will give this a try tomorrow first thing....
                today I have to watch the Euro Final!
                  Website: www.mercologia.com
                  MODX Revo Tutorials:  www.modxperience.com

                  MODX Professional Partner
                  • 4310
                  • 2,310 Posts
                  That’s still over two hours away!
                  Plenty of time to finish your site grin
                    • 25663 MODX Staff
                    • 12,272 Posts
                    Quote from: pierun at Jun 29, 2008, 05:31 AM

                    I don’t think you can do that trick in the CSS, since the CSS is included and not parsed by MODx

                    You can actually use a custom content type and a blank template to create CSS files that are parsed by MODx.
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me