We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15826
    • 160 Posts
    I know there’s gotta be a simple way to do this. I have some general sections of the website. I wish to have an icon image for each section and have it included in a certain div in the section document and all children of that section. How? And please spell it out completely, don’t just tell me to use a tv or this or that, which will just result in more frustration on my part. I’ve been on this board for a few hours trying to figure it out and trial and errored (with every time being an error) a number of ways and haven’t gotten it right yet.

    Each image in question is the same size and named the same as the alias of the parent document. All are the same file format.
      "I’d love to change the world but I can’t find the source code . . ."

      Custom ModX Templates
    • 1) Create a TV call [*sectionImage*]. Default value @INHERIT. Type raw text.

      2) Structure the top page of each section as a folder document.

      3) In your template, place the following bit of code: <img src="[*sectionImage*]" alt="" />

      4) In the top folder sections, on the sectionImage TVs, insert the image including path.

      What it does:
      @INHERIT is an "@binding" that looks up the document heirarchy until if finds a non-blank value in that branch, and applies that value to every document. You can override it on a per-page basis if you like. @INHERIT is one of MODx’s hidden gems. smiley
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 15826
        • 160 Posts
        THANK YOU! You just gifted me with a LIGHTBULB MOMENT!

        Watch out! Kickass is now on the LOOSE!
          "I’d love to change the world but I can’t find the source code . . ."

          Custom ModX Templates
          • 7455
          • 2,204 Posts
          you could aslo use a snippet like UltimateParent or SectionRoots to generate an unique filename like this:

          say you have 4 general sections that are in the root of your site, being id 1 2 3 and 4 make 4 images with a name that includes one of the id’s, e.g. image1.jpg image2.jpg image3.jpg and image4.jpg

          then call the image this way <img src="assets/images/image[!UltimateParent!].jpg />"
          UltimateParent wil fill in the ID and your image path is compleet.
          thats how I use it a lot no need for extra tv’s

          if your sections are not in the root than u can use SectionRoots instead of UltimateParent
            follow me on twitter: @dimmy01