We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33969
    • 60 Posts
    I am writing some code for an online contest. I used Formit for the form - then added a customHook to load the 'contest' package.

    It ran fine on my development server but failed on the staging and production servers.

    The code to add the package is:
    $basePath = MODX_BASE_PATH . 'core/components/contests/';
    $this->config = array_merge(array(
    	'basePath' => $basePath,
    	'corePath' => $basePath,
    	'modelPath' => $basePath.'model/',
    	'processorsPath' => $basePath.'processors/',
    	'templatesPath' => $basePath.'templates/',
    	'chunksPath' => $basePath.'elements/chunks/',
    ),$config);
    $p = $this->modx->addPackage('contests',$this->config['modelPath']);


    The problem was with "$this->config['modelPath']". Instead of being ending with "/core/components/contests/model/" it ended with "/core/components/formit/model/". None of the other paths had that problem.

    I fixed it by forcing the change with:

    $config['modelPath'] = MODX_BASE_PATH . 'core/components/contests/model/';


    The staging and production sites are hosted on Blue Host. I suspect it has something to do with configuration - but have no idea what.

      Michael Regan
      TIMR Web Services
      Phone: 250.218.5284
      Eamil: [email protected]
      Website: timr.ca
      • 3749
      • 24,544 Posts
      I don't think it's host-related. I think FormIt is setting $scriptProperties['modelPath'] to its own model directory, overwriting your value. If you're sending that as a property in the tag, try using a different name for it (e.g. fwa.modelPath). It's a good idea to prefix any properties you're sending through to a hook.
        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
        • 33969
        • 60 Posts
        Thanks - I like the idea of adding the prefix. I do that in naming TV's, Chunks, etc. but never thought of doing it in my coding as well.
          Michael Regan
          TIMR Web Services
          Phone: 250.218.5284
          Eamil: [email protected]
          Website: timr.ca