We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38925
    • 38 Posts
    Hi !

    Is it possible to use lexicon with ModX logs ? I didn't suceed so far.

    Thank you
      • 3749
      • 24,544 Posts
      You have to know the lexicon key, but this should work:

      $msg = $modx->lexicon('lexicon_key');
      $this->modx->log(modX::LOG_LEVEL_ERROR,$msg);
      // or
      $this->modx->log(modX::LOG_LEVEL_INFO,$msg);
      


      If it's your own lexicon rather then MODX's, you'll need to use this above the log call:

      $modx->lexicon->load(mycomponent:mytopic);



      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        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
        • 38925
        • 38 Posts
        Sorry I forgot to say that I'm using Revo 2.2.1

        I add this :

        $modx->lexicon->load('importusersx:default');
        	
        	$sLog = $modx->lexicon('importusersx');
        	$modx->log(modX::LOG_LEVEL_INFO,$sLog);


        My lexicon file is in core/components/importusersx/lexicon/fr/default.inc.php and I have this key :

        $_lang['importusersx'] = 'ImportUsersX';


        But log shows just 'importusersx'.

        Thank you
          • 3749
          • 24,544 Posts
          Try this:

          $modx->lexicon->load('fr:importusersx:default');  




          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 38925
            • 38 Posts
            No changes sad

            How can I check if the lexicon is correctly loaded ? I think that the key is good (since it works in my controller) but we never know.
              • 3749
              • 24,544 Posts
              Just put a snippet tag on a page and put this in the snippet:

              $modx->lexicon->load('fr:importusersx:default');
              return $modx->lexicon('importusersx');


              You probably know this, but I pasted my code for the log message from a class. If yours is not in a class, you'd want this instead:

              $modx->log(modX::LOG_LEVEL_INFO,$msg);



              Change it to this to see if you're getting any logging at all:

              $modx->log(modX::LOG_LEVEL_INFO,'xxx' . $msg . 'xxx');


              BTW, you did look in the error log, right? That's where the message will go if you didn't change the log target.


              Another thing to try would be to call it with one of the core lexicon entries to see if the lexicon is working at all:

              return $modx->lexicon('access_denied');





              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 5 months ago.]
                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
                • 38925
                • 38 Posts
                I changed the log target with

                $modx->setLogTarget('ECHO');


                The log works very well, the problem is that my lexicon don't works in the snippet. With the key 'importusersx', I should have 'ImportUsersX' but it returns this :


                [2012-04-21 06:42:37] (INFO @ /ct37/assets/components/importusersx/elements/import.php) importusersx

                  • 3749
                  • 24,544 Posts
                  I'm not sure it will help, but it can't hurt to put this at the top:

                  $modx->getService('lexicon','modLexicon');



                  You could also try this just above the lexicon->load():

                  $modx->setOption('cultureKey', 'fr');
                  $modx->setOption('manager_language', 'fr');
                  




                  ------------------------------------------------------------------------------------------
                  PLEASE, PLEASE specify the version of MODX you are using.
                  MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 5 months ago.]
                    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