We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17499 ☆ A M B ☆
    • 872 Posts
    Hello,

    I’m converting a snippet for Revolution, and playing with all the new features.

    Copying the behaviour of another snippets, i wanted default properties to show when i drag & drop a snippet in textarea.
    Am i doing something wrong?

    Snippet code:

    <?php
    $cumulus_path = $modx->getOption('core_path').'components/cumulus/';
    if (!class_exists('Cumulus')){
        $modx->addPackage('cumulus',$cumulus_path.'model/');
        $modx->loadClass('cumulus.Cumulus',$cumulus_path.'model/',true,true);
    }
    $Cumulus = new Cumulus($modx,$scriptProperties);
    return $Cumulus->getOutput();
    ?>
    


    Class code:

    <?php
    class Cumulus {
    
        function Cumulus(&$modx,$config = array()) {
            $this->__construct($modx,$config);
        }
    
        function __construct(&$modx,$config = array()) {
            $this->modx =& $modx;
    
            $this->config = array_merge(array(
                'parent' => "1", 
    	    'depth' => 10,
    	    'days' => 0,
    	    'min' => 0,		
    	    'landing' => "[[~[[*id]]]]",
    	    'tvTags' => "tags",			
    	    'tagDelimiter' => ",",				
            ),$config);
        }
    
    }
    ?>
    
      • 22303 MODX Staff
      • 10,725 Posts
      Did you create the default properties on the snippet? That’s what triggers that behavior...
        • 17499 ☆ A M B ☆
        • 872 Posts
        I copied the googlesitemap snippet which is the same code as posted in the first box (Cumulus replaced by GoogleSiteMap), there are not any lines specifying the default properties and the default properties can be found in the class with the construct function (I’m still talking about the googleSiteMap snippet).

        Maybe i missed something...
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: lossendae at Aug 25, 2009, 12:19 PM

          Maybe i missed something...
          Yes, you can now define Default Properties, and additional named Property Sets, in the manager UI when editing a Snippet. Click on the Properties tab and you can define Default Properties which are automatically applied to all instances of the Snippet unless overridden by properties from a named Property Set AND/OR traditional Snippet Parameters provided directly in the Tag.
            • 17499 ☆ A M B ☆
            • 872 Posts
            Thank you Jason.

              • 28215
              • 4,149 Posts
              Lossendae,

              Those are "automatically" put in to GoogleSiteMap because of the build script for that package when it puts it into the transport.zip file. If you’re wanting to distribute your Cumulus 3PC, you’ll need to create a transport package to do so, and make sure all the default properties you put on your snippet (or snippets - you can have different default props for different snippets should you have more than 1 Element in the package) are also built in. While you’re developing it, though, Jason is right - you can just use the Properties grid. That’s how the Drag/Drop feature builds its stuff.

              You can see how GoogleSiteMap does that here:

              http://svn.modxcms.com/svn/modx-components/googlesitemap/trunk/_build/

              Also you can refer to my tut on creating a build script here:

              http://svn.modxcms.com/docs/display/revolution/Creating+a+3rd+Party+Component+Build+Script

              Let us know if you have more questions.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com