We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13735
    • 62 Posts
    Hello,

    I wanted to create a build script for my snippet. I add the properties like this:
    $snippet->setProperties(file_get_contents(dirname(__FILE__) . '/snippet.ggviewer.properties.txt'));

    The text file contains the exported json string with the properties.

    I get the following error:
    Fatal error: Call to a member function parsePropertyString() on a non-object in /Users/Josef/Documents/Entwicklung/MAMP/GalleryGear/core/model/modx/modelement.class.php on line 495

    My guess is that MODx hasn’t loaded the parser. But I don’t know how to load it.

    Can you help me?

    Regards,
    JB
      • 28215
      • 4,149 Posts
      setProperties expects an array. Try this:
      $props = file_get_contents(dirname(__FILE__) . '/snippet.ggviewer.properties.txt');
      $props = $modx->fromJSON($props);
      if (!empty($props)) {
        $snippet->setProperties($props);
      }
      
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 13735
        • 62 Posts
        Thanks a lot!
          • 3749
          • 24,544 Posts
          You might also take a look at the GetMyComponent package, which installs MyComponent. It has examples of almost everything you might want to do in a build script and can be modified and used to create your own package.

          There’s a tutorial for it here: http://bobsguides.com/mycomponent-tutorial.html
            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