We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    How would I go about assigning a System Setting such as "site_unavailable_page" if my package also installs the resource to be used as the site unavailable page? It can't know the resource ID until the resource has been inserted.
      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
      • 3749
      • 24,544 Posts
      A resolver will run after the page has been installed.

      $doc=$modx->getObject('modResource', array('pagetitle' => 'MyPage'));
      if ($doc) {
         $docId = $doc->get('id');
         $ss = $modx->getObject('modSystemSetting', array('key' => 'site_unavailable_page'));
      
         if ($ss) {
             $ss->set('value', $docId);
             $ss->save();
         }
      }


      During development, you'll probably want some else statements with:

      $modx->log(modX::LOG_LEVEL_ERROR, 'Some Message');
        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