We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    It appears that the document parser in both Evo and Revo will now handle entified ampersands (&) as prefixes to snippet parameters.

    This seems to work fine:

    [[snippetname? &param1=`value`]]


    I just wanted confirmation that we no longer have to tell users to turn off the RTE to use snippet tags?
      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
      • 25663 MODX Staff
      • 12,272 Posts
      It’s worked in Evo for years, and my gut says there’s no issue in Revo and it won’t be removed as working there. I’ll let Jason confirm for certain though. smiley
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Yes, the parser does check for & and behaves as expected. However, sometimes (primarily when copy/pasting) an overzealous TinyMCE can double up on the & producing & which will break the snippet (one can only go so far in checking for weird stuff in the parameter list). However, it is fairly trivial to modify a snippet to accept an external config file, so the snippet only needs one parameter
        [[SnippetName?config=`name`]]

        Then in the beginning of the snippet code add something like
        $config = isset($config) ? $config : 'default';
        $configfile = 'assets/snippets/mySnippet/configs/' . $config . 'inc.php';
        if(file_exists($configfile)) { include $configfile; }
        

        This means also adding a directory in the assets/snippets/mySnippet directory, and having a file named default.inc.php there. It can be empty, or contain basic default values if desired.

        Now you can create all the config files you need for different snippet calls, and in the snippet tags you only need the one parameter to indicate which config file to use. And TinyMCE can’t mess up the snippet call.
          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
          • 22303 MODX Staff
          • 10,725 Posts
          FYI, in Revolution, using named Property Sets is similar to (though more efficient than) using an external config file, as you can define and edit the configurations directly in the manager, and your content editors need only provide the name of the property set to apply, i.e.
          [[Snippet@PropertySetName]]
          This will become the best practice in Revolution for applying the properties that have traditionally been defined in snippet parameters. In addition, this same technique will also work with all other Elements, including Chunks, Template Variables, even Plugins and Templates, though Plugins apply the Property Sets when being registered with an Event and Templates can only use default properties applied directly to the Template instance.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            ...Templates can only use default properties applied directly to the Template instance.
            What does this mean?

            I hated this 20 years ago when I began teaching myself programming, and I hate it now; I know what the individual words mean, but together I can’t make sense of the statement.
              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
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: sottwell at Aug 16, 2009, 11:25 PM

              ...Templates can only use default properties applied directly to the Template instance.
              What does this mean?
              In the terminology established for Revolution, it means that since Templates are not called with Tags, you cannot use the PropertySet syntax, i.e.
              [[TemplateName@PropertySetName]]
              But since you can define default Properties for any Element, a single Template can still have a single set of Properties defined. With Elements that contain content (vs. PHP scripts), these Properties are turned into Placeholders within the scope of processing for the Element.

              Regardless if these details makes sense to those not yet immersed in Revolution, the important part within this conversation was the introduction to Property Sets.
                • 3749
                • 24,544 Posts
                I’m glad I asked. I could swear that in 0.9.6 a single & has screwed up a snippet call, but it hasn’t happened for a while because I almost never use the RTE.

                As you say, default properties and property sets are definitely the way to go in Revo for lots of reasons. I’m sure there will still be cases, though, where people want to override them by sending a parameter in the snippet call and lot’s of legacy snippets won’t have any properties for a while.

                Not to mention the recalcitrant coders who don’t want to change (not thinking of anyone in particular . . .). wink
                  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