We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    Ok, I’ve been working on a site upgrade/redesign for several days. Four languages, cookies, random images and other goodies. Fairly straightforward stuff.

    Late last night I worked out how to use a single eForm template for all four languages. Add my form prompts to the language files, then create a nice little function for the eFormOnBeforeFormMerge event:
    <?php
    function setPrompts(&$fields) {
        global $_lang;
        $fields['yourname'] = $_lang['yourname'];
        $fields['youremail'] = $_lang['youremail'];
        $fields['yourmessage'] = $_lang['yourmessage'];
        $fields['sendmessage'] = $_lang['sendmessage']; // for the submit button
        return true;
    }
    ?>

    Works like a charm... except for the German form. Blank page. After banging my head against the wall for a while, I gave it up and went to bed. This morning I got back to it, and picked apart my code, from the snippets setting and getting the user’s language choice to and from a cookie, to the site template and the eForm template.

    Then I sat back and said to myself "The only difference between this German page and the other three languages is that I’m setting the &language value in the eForm snippet call to `german` instead of `english` etc. Then the light went on... the german language file!!! And there it was... one of the entries was missing its ending semicolon. rolleyes
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 7231
      • 4,205 Posts
      Then the light went on... the german language file!!! And there it was... one of the entries was missing its ending semicolon.
      Good troubleshooting story.

      Those semicolons are like gremlins, they are always getting their laughs by disappearing on us. I can just imagine them getting together in the code and planning where they will strike next. I heard that they are upset since they are always last, at the end of the line, and they get even by trying to make us look like fools. Not like the dollar signs, they are always where you left them...a much prouder symbol because they are always in front. There is a great amount of jealousy between characters, numbers, punctuation marks and symbols in the world of code. Every once in a while they get together and revolt and it looks like this:
      ’[-+]?\b[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?\b’
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Heh. I can well believe it!

        This is also about the extender snippet for eform; I’ve written a page in the Wiki about this for using the eForm lang files for multilanguage form templates.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 3749
          • 24,544 Posts
          I’ve definitely been there. The other night, I spent three hours chasing down a missing quotation mark. It serves me right for not installing the code highlighter plugin.

          Bob
            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