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
    SPForm creates two resources (contact form and "Thank You’ page). I don’t want those resources updated on upgrade or reinstall because the user is likely to have customized them. If I set UPDATE_OBJECT to false in the attributes for those resources, though, they aren’t removed on uninstall.

    Is this a PM bug, or am I doing something wrong?

      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
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: BobRay at Jul 20, 2010, 01:06 AM

      SPForm creates two resources (contact form and "Thank You’ page). I don’t want those resources updated on upgrade or reinstall because the user is likely to have customized them. If I set UPDATE_OBJECT to false in the attributes for those resources, though, they aren’t removed on uninstall.

      Is this a PM bug, or am I doing something wrong?
      Specifying update object as false essentially says that the install and uninstall processes on the package should ignore these objects if they already exist.
        • 3749
        • 24,544 Posts
        Quote from: OpenGeek at Jul 21, 2010, 10:47 AM

        Quote from: BobRay at Jul 20, 2010, 01:06 AM

        SPForm creates two resources (contact form and "Thank You’ page). I don’t want those resources updated on upgrade or reinstall because the user is likely to have customized them. If I set UPDATE_OBJECT to false in the attributes for those resources, though, they aren’t removed on uninstall.

        Is this a PM bug, or am I doing something wrong?
        Specifying update object as false essentially says that the install and uninstall processes on the package should ignore these objects if they already exist.

        Right, that’s exactly what I want for the resources (UPDATE_OBJECT = false), but if I do that, they aren’t uninstalled when the package is -- even on a clean install followed immediately by an uninstall.
          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
          • 28215
          • 4,149 Posts
          Can you post your resolver code here? I’m willing to bet it’s because you aren’t doing the xPDOTransport::PACKAGE_ACTION switch.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 3749
            • 24,544 Posts
            Actually, I think some of it is your code. wink

            Shouldn’t they be removed with or without the switch?
            I can’t remove them myself, because I can’t count on being able to find them.

            <?php
            /**
             * @package spform
             * @subpackage build
             */
            $resources = array();
            
            $modx->log(modX::LOG_LEVEL_INFO,'Creating resource: Contact Page<br />');
            $resources[1]= $modx->newObject('modResource');
            $resources[1]->fromArray(array(
                'id' => 1,
                'class_key' => 'modResource',
                'context_key' => 'web',
                'type' => 'document',
                'contentType' => 'text/html',
                'pagetitle' => 'Contact',
                'logtitle' => 'Contact Us',
                'description' => 'Spam-proof Contact Form',
                'alias' => 'contact',
                'published' => 1,
                'parent' => 0,
                'isfolder' => 0,
                'richtext' => 0,
                'menuindex' => 99,
                'searchable' => 0,
                'cacheable' => 1,
                'menutitle' => 'Contact Us',
                'donthit' => 0,
                'hidemenu' => 0,
            ),'',true,true);
            $resources[1]->setContent('[[!SPForm]]');
            
            $modx->log(modX::LOG_LEVEL_INFO,'Creating resource: Response Page<br />');
            $resources[2]= $modx->newObject('modResource');
            $resources[2]->fromArray(array(
                'id' => 2,
                'class_key' => 'modResource',
                'context_key' => 'web',
                'type' => 'document',
                'contentType' => 'text/html',
                'pagetitle' => 'Thank You',
                'logtitle' => 'Thank You',
                'description' => 'Spam-proof Contact Form "Thank You" page',
                'alias' => 'thankyou',
                'published' => 1,
                'parent' => 0,
                'isfolder' => 0,
                'richtext' => 0,
                'menuindex' => 99,
                'searchable' => 0,
                'cacheable' => 1,
                'menutitle' => 'Thank You',
                'donthit' => 0,
                'hidemenu' => 1,
            ),'',true,true);
            $resources[2]->setContent('[[!SPFResponse]]');
            
            return $resources;
            
              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