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


    I need to create a plugin/snippet in modx revolution to save any lexicon entry to a file as sql when it will be created/updated. I also need to check duplicate when i will save this.

    if i use plugin:
    I need to set plugin event when some one will create or update a lexicon entry from modx lexicon management.I want to save created/updated lexicon entry to somewhere else.

    if i use snippet :
    when and where should i call snippet.


    I have been searching in googles and see modx documentations. I could not find useful links. Any ideas or links will be helpful.

    Thanks,
    Awlad
      • 3749
      • 24,544 Posts
      AFAIK, there is no System Event that fires when a lexicon entry is saved. So a plugin is out and a snippet would not execute when you needed it to.

      The situation is complicated because there are the lexicon entries in the core/lexicon directory, but they are overridden by any entries in the database entered in Lexicon Management.

      The original lexicon entries are already in files in the core/lexicon directory (or in core/components/componentname/lexicon for MODX extras), but saving a lexicon entry in Lexicon Management doesn't change them.

      The only way I can think of to do what you want is to create a form for users to set lexicon entries and use it to set them in the DB, or in the files, or both, and then use the information to update your SQL file.

      You can get all the lexicon entries with a particular prefix by calling $modx->lexicon->fetch('prefix'), but that's no good unless all your lexicon keys have the same prefix.
        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
        • 44427
        • 7 Posts
        @BobRay
        Thanks for your quick response. I think i need to find another alternative way to solve my problems.