We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19872
    • 1,078 Posts
    Genius!
      • 19872
      • 1,078 Posts
      Hmmm? Build one snippet instead of a bunch.

      I'm going to redo some of my structure right away. This has opened up a whole realm of possibilities.

      Thank you.
        • 19872
        • 1,078 Posts
        So I set up the snippet, named it sellingPoints, and then called it on the page like so:

        [[sellingPoints? &tvname=`fireplaceQty` &tpl=`<li><smalllabel>FIREPLACE:</smalllabel>[[+value]] </li>`]]


        I'm getting a syntax error on line 8. Unexpected '{'

        I'm going to review some of my php tutorials again to better understand what the script is doing.
          • 4172
          • 5,888 Posts
          It was a missing ) in that line

          if (!empty($tvname) && !empty($tpl)) {


          corrected the code
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 19872
            • 1,078 Posts
            Aha! That works. Thank you.
              • 19872
              • 1,078 Posts
              I was reviewing the Output Modifiers, and discovered the following successfully yields the same result.
              [[*fireplaceQty:notempty=`<li><smalllabel>FIREPLACE:</smalllabel>[[*fireplaceQty]] </li>`]]


              Since it's a simple Text TV, maybe the output modifier is OK to use.

              Certainly, learning to write my own snippets though will go a long way in helping me learn PHP:)
                • 3749
                • 24,544 Posts
                The snippet will be much faster because of the time it takes MODX to parse the tag, then find the output modifier and run it. Otoh, if the page is cached, it may not make much difference.
                  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
                  • 19872
                  • 1,078 Posts
                  Quote from: BobRay at Feb 24, 2015, 04:01 PM
                  The snippet will be much faster because of the time it takes MODX to parse the tag, then find the output modifier and run it. Otoh, if the page is cached, it may not make much difference.

                  I do have the page cached. I already converted the entries to output modifiers, but can easily implement the snippet if I sense slowness.

                  Moving forward I hope to gain a better understanding of when and why to use certain methods for implementing the content of a site. Your assistance on the forum is greatly appreciated.