We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15987
    • 786 Posts
    I am creating a couple of snippets and would like them to share a default set of properties. Is this possible? I created a custom property set, but then you have to put that in the snippet call.

    Maybe I’m just missing something here, working on stuff at 2 am is getting harder to do as I get older.
      • 3749
      • 24,544 Posts
      Using a custom property set would be the normal way of doing it, but you could grab either the default properties of another snippet or the custom property set in the snippet code with

      <?php
      $object = $modx->getObject('modSnippet',$id);  // to get default props of the other snippet
      //or
      $object = $modx->getObject('modPropertySet',$id); // to get the custom property set
      
      // then get the properties with 
      $props = $object->getProperties();
      
      // and then merge them with the $scriptProperties array.
      ?>


      That way you wouldn’t need to specify them in the snippet tag.
        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
        • 15987
        • 786 Posts
        Bob, thanks for the tip. I hadn’t thought about doing it in the snippet code.