We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13735
    • 62 Posts
    Hello,

    I need access to the lexicon from javascript. My idea was to pass the entries of a complete lexicon file into a javascript variable (simple "jsonify" a php array with all the lexicon entries of that file). I know that there is $modx->lexicon(’some_key’) but this one only returns a certain lexicon entry. Is there a sleek way to return all entries from a certain file/topic?

    JB
      • 28215
      • 4,149 Posts
      splittingred Reply #2, 16 years ago
      You can use $modx->lexicon->fetch($prefix = ’’,$removePrefix = false). That will return an array of lexicon strings. You can also pass in a prefix that will filter by that prefix (of keys), and use $removePrefix if you want to strip the prefix.

      Then just use $modx->toJSON($array) to turn it into JSON.

      Note, though, there was a bug in 2.0.0 - you’ll need to apply this patch to get it to work: http://github.com/modxcms/revolution/commit/1c5be35b31fd9457ca397713b399b13bc490337d

      It’s been fixed for 2.0.1.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 13735
        • 62 Posts
        Thanks a lot! I really like this forum!

        I’ve simply edited the file and it works. Just wondering: Do you already have plans when you will the 2.0.1 update?
          • 28215
          • 4,149 Posts
          splittingred Reply #4, 16 years ago
          Hopefully sometime in the next few weeks. There are a couple of external factors that might slow this down, but we do plan to get on a 6-week or so release cycle for Revolution.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com