We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7869
    • 118 Posts
    I’ve read this term "templatable output" when trying to understand snippets. What does it mean? Can anyone give an example or post a link that explains it. The MODx docs have me at a loss. huh

    I’m using a snippet called pieX. It pulls RSS feed data, and then it displays in it’s own way (as a bullet list). If it was "templatable" would that mean I can control how the output looks and if so, how?
      -Dorian
      • 3749
      • 24,544 Posts
      It means that the snipppet produces its output by setting placeholders and rendering a tpl that contains those placeholders.

      Say you have a snippet that gets information on a particular user from the DB and puts it on the screen.

      The tpl chunk might look like this:

      <div class = "user_info">
      
      Name: [+user_name+]<br />
      
      Address: [+user_address+]<br />
      
      Email: [+user_email+]
      
      </div>

      If you wanted to change how the output looked, you’d create your own tpl chunk, let’s call it "MyTpl." You could add a phone number or some other data available in the snippet. You could also change the HTML and the class names. Then you’d just pass the name of that chunk to the snippet:

      [[SnippetNamet? &tpl=`MyTpl`]]


      The snippet will replace the placeholders (the things between the + signs) it recognizes and send the result off to the browser.

      This lets you have great control over the visual presentation of the snippet’s output without touching the code of the snippet or worrying about your work being destroyed when you update the snippet to a new version.

        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
        • 7869
        • 118 Posts
        Thanks! So if I understand correctly, this template (tpl) will display right there in your web page much like a chunk does, correct?

        If the snippet has little (or really bad) documentation, how do you know what [+placeholders+] are available?
          -Dorian
          • 36592
          • 970 Posts
          Quote from: DorianJ at Dec 18, 2008, 01:09 AM

          If the snippet has little (or really bad) documentation, how do you know what [+placeholders+] are available?
          Regarding pieX, you can find its documentation here. -> http://wiki.modxcms.com/index.php/PieX
          See the placeholder section of this page to find what placeholders you can use with pieX.
            • 7869
            • 118 Posts
            Thanks, I’ve been reading that page and the snippet pulls data from eBay RSS out-of-the-box, but I can’t figure out how to display it the way I want. I’ve been trying so long to get FeedX to work and I can’t figure it out. How does someone know if they should use FeedX or PieX (or simple pie or whatever it’s called)?
              -Dorian
              • 36592
              • 970 Posts
              Quote from: DorianJ at Dec 18, 2008, 02:19 AM

              I can’t figure out how to display it the way I want.
              How do you want to display the feed ?
              Don’t you give us an HTML example ?
                • 7869
                • 118 Posts
                I’m not sure how to answer this, but for an ebay feed, I would like to display the data like this...

                PICTURE | TITLE | PRICE | LINK

                The best I can do with FeedX is display only the TITLE of each item.

                PieX displays everything I want, but it looks like this...

                PICTURE | PRICE
                DATE | TIME
                PRICE
                LINK | TITLE
                  -Dorian