We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20080
    • 17 Posts
    I’m very new to Modx about 2 weeks old and just had a difficult time re-thinking the way I write my PHP. (Probably because I was not born very smart.)

    Im very sure there is an easier or maybe more elegant/recomended way of doing this, but I had to post this just in case someone else out there is like me.

    Here is my snippet:
    <?php //test_snippet for simple placeholders
    
    $first = 'Joe';
    $last = 'Shmoe'; // I think that's how its spelled.
    $mynumber = '777'; //Feeling lucky
    
    $modx->setPlaceholder('first',$first);
    $modx->setPlaceholder('last',$last);
    $modx->setPlaceholder('number',$mynumber);
    
    //That's it for the snippet.
    ?>
    


    This could be in either a chunk or inside the actual content. I put this in my content, just to keep it simple.
    <p>My Name is: [+first+]. My Last Name is: [+last+]. My Lucky number is: [+mynumber+].</P>
    



    To my astonishment it worked and displayed this.

    My Name is: Joe. My Last Name is: Shmoe. My Lucky number is: 777.


    I read this post a few times which helped me realize how simple this really could be. My primary purpose for doing this was to create a prefilled fird with data from a custom table. http://modxcms.com/forums/index.php?topic=43393.0

    II am very open to suggestions whic will surely add to the enlightment. I’d like to put them into an array and then call them just like above. maybe even like [+myarray.first+], etc, but I have not tested or tried that.

    So is it pronounced "mod-ex" like modular x or like mode-ex?
      www.DMSalesSolutions.com New Site using Modx (still learning though)
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      mod-ex. Modular, extensible. Maybe this will help you understand what’s going on.

      http://sottwell.com/modx-from-the-inside.html
        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
        • 21242
        • 30 Posts
        I have been scanning the Wiki files and the Forum, for any form of default placeholder list.

        Has MODx Revo been made so flexible, that the ’core’ placeholders also have to be defined?

        I’m really looking for the placeholder for "Summary (introtext)", and was hoping there is a cheatsheet of other [[+placeholders]] that could be useful...
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          There are no "core" placeholders. The placeholders array is a convenience for snippet and plugin developers. What you are thinking of as "core placeholders" are described here.

          http://sottwell.com/how-templates-work.html

            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
            • 21242
            • 30 Posts
            Thanks Susan, I’m confusing [[+placeholders]] with Template (or Resource) Variables [[*introtext]]
            Is there a full list of built in Template Vars available?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Take a look at the site_content table; the built-in resource variables are those. As I mentioned in my article, most of them aren’t of much use to a designer.
                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
                • 26931
                • 2,314 Posts
                anonymized-26931 Reply #7, 16 years ago
                  • 21242
                  • 30 Posts
                  cool Thank you Sharkbait, Thanks Susan!
                    • 20080
                    • 17 Posts
                    Thanks Susan for the link. Good info. Helps lots!
                      www.DMSalesSolutions.com New Site using Modx (still learning though)
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      That whole MODx From The Inside is for Evo, BobRay is making a real Revo book.
                        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