We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28215
    • 4,149 Posts
    I figured this was the case; your solution wont work without reloading the $modx->config array. Settings are cached and stored there so that they dont have to use up queries each runtime.

    So, if you have added a Setting and want to dynamically reload the config without first clearing the cache, you’ll need to run this method:

    $modx->reloadConfig();
    


    This will clear the cache and reload the settings into $modx->config.
      shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
      • 29606
      • 63 Posts
      Still no luck sad

      $modx->getOption(’SMF_ID’) still is empty, even after I cleared the cache or used $modx->reloadConfig();
        • 21257 MODX Staff
        • 730 Posts
        Are you getting the $id that you expect from $id=$user->get(’id’); ?
          Mike Schell
          Lead Developer, MODX Cloud
          Email: [email protected]
          GitHub: https://github.com/netProphET/
          Twitter: @mkschell
          • 29606
          • 63 Posts
          Quote from: netProphET at Aug 11, 2009, 04:38 PM

          Are you getting the $id that you expect from $id=$user->get(’id’); ?

          I double checked this at first, and I am getting the right ID. I’ve used this in another snippet for some times now and it works perfectly.

          I made a print_r($modx) to a file, and noticed that the _userConfig arry only contains the settings I created in the User tabs, not the one from the code. However, they both appear in the "modx_user_settings" table from the database.
            • 21257 MODX Staff
            • 730 Posts
            At this point I’d start tracing the xpdo logs because you might find an error there.

            Here’s a quick sample of getting xPDO to log to a file - modify as per your MODx application:

            $xpdo->cachePath = CACHE_PATH;
            $xpdo->setDebug(true);
            $xpdo->setLogLevel(XPDO_LOG_LEVEL_INFO);
            $xpdo->setLogTarget('FILE');
            

              Mike Schell
              Lead Developer, MODX Cloud
              Email: [email protected]
              GitHub: https://github.com/netProphET/
              Twitter: @mkschell
              • 21257 MODX Staff
              • 730 Posts
              Are you calling this code from an uncached snippet and/or resource?
                Mike Schell
                Lead Developer, MODX Cloud
                Email: [email protected]
                GitHub: https://github.com/netProphET/
                Twitter: @mkschell
                • 29606
                • 63 Posts
                Quote from: netProphET at Aug 11, 2009, 05:01 PM

                $xpdo->cachePath = CACHE_PATH;
                $xpdo->setDebug(true);
                $xpdo->setLogLevel(XPDO_LOG_LEVEL_INFO);
                $xpdo->setLogTarget('FILE');
                


                This code gives me a : Fatal error: Call to undefined method stdClass::setDebug() in D:\xampplite\htdocs\online\core\model\modx\modscript.class.php(96) : eval()’d code on line 42

                The snippet call is uncached in a cached ressource. Could this be an issue ? I figure that as long as the snippet is uncached, there is no problem ?
                  • 28215
                  • 4,149 Posts
                  Try $modx instead of $xpdo.
                    shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                    • 29606
                    • 63 Posts
                    Quote from: splittingred at Aug 11, 2009, 05:13 PM

                    Try $modx instead of $xpdo.

                    Ok, this worked, now I have a 5000 lines error log. What am I looking for ?
                      • 3749
                      • 24,544 Posts
                      Quote from: Thalion at Aug 11, 2009, 02:50 PM

                      I’m using SVN 5627, I don’t know if the change happened before or after ? Either way, $modx->user->getMany(’UserSetting’) is empty as well...

                      Clearing the cache doesn’t change anything
                      Look in the file /core/model/schema/modx.mysql.schema.xml

                      look for
                      - <object class="modUser"

                      Check the aggregate aliases. You might as well be using the correct alias before doing any further debugging. wink
                        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