We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6910
    • 1 Posts
    so in 34.include.cache.php, $modx is returning NULL...
    hence the errors..

    but in my external file $mod is returning the object...

    define('MODX_CORE_PATH', '/var/www/vhosts/mydomain/httpdocs/core/');
    define('MODX_CONFIG_KEY', 'config');
    define('MODX_API_MODE', true);
    
    
    require_once '/var/www/vhosts/imi.ie/httpdocs/connectors/config.core.php';
    require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
    require_once MODX_CORE_PATH.'model/modx/modx.class.php';
    $modx = new modX();
    $modx->initialize('web');
    $modx->getService('error','error.modError');
    
    var_dump($modx)
    

    • The config file should not be included manually before instantiating the modX class. This is done internally when you call new modX().
        • 6910
        • 1 Posts
        just following what the manual says....
        http://rtfm.modx.com/display/revolution20/Loading+MODx+Externally

        require_once '/absolute/path/to/modx/config.core.php';
        require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
        require_once MODX_CORE_PATH.'model/modx/modx.class.php';
        $modx = new modX();
        $modx->initialize('web');
        $modx->getService('error','error.modError');
        
        • Edited for the inaccuracy...
            • 6910
            • 1 Posts
            updated my file and still no joy. I’ve tried with both the simplsearch and wayfinder and a similar error in both.

            Now i’ve gone into both of the include files throwing the errors, and in both instances, when it calls the "global $modx;", it is not becoming the modx object.
            i’ve var_dump’d it and it’s returning a null


            from 24.include.cache.php
            function elements_modsnippet_24($scriptProperties= array()) {
            global $modx;
            
            if (is_array($scriptProperties)) {
            extract($scriptProperties, EXTR_SKIP);
            }
            /**
             * Wayfinder Snippet to build site navigation menus
             *
             * Totally refactored from original DropMenu nav builder to make it easier to
             * create custom navigation by using chunks as output templates. By using
             * templates, many of the paramaters are no longer needed for flexible output
             * including tables, unordered- or ordered-lists (ULs or OLs), definition lists
             * (DLs) or in any other format you desire.
             *
             * @version 2.1.1-beta5
             * @author Garry Nutting (collabpad.com)
             * @author Kyle Jaebker (muddydogpaws.com)
             * @author Ryan Thrash (modx.com)
             * @author Shaun McCormick (modx.com)
             * @author Jason Coward (modx.com)
             *
             * @example [[Wayfinder? &startId=`0`]]
             *
             */
            $wayfinder_base = $modx->getOption('wayfinder.core_path',$scriptProperties,$modx->getOption('core_path').'components/wayfinder/');
            
              • 6910
              • 1 Posts
              well have given up trying to do it the api way....

              gone with the old reliable file_get_contents(link_to_resource_displaying_masthead_and_menu);