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

    I wonder how do we manage the multilingual alias in revolution ?

    When entering a lexicon call in the alias field, it strips the illegal characters when saving. :’(

    In my humble opinion it should replace the tag by the lexicon entry first and then only strip chars.

    Is it a bug ? (if yes i will jira it)

    EDIT : seems like there is the same problem with lexicon tags inside attached documents that do not convert.
      • 22303 MODX Staff
      • 10,725 Posts
      Aliases cannot be dynamic values and a single Resource does not get served by multiple aliases in MODx Revo (or Evo). Never has, never should, and never will.

      This is NOT a bug. Multilingual extensions will be developed to help you localize content by creating new Resources with a different alias or the same alias and a different location in the tree structure, depending on how you choose to approach your site localization, just like they were for Evo.

      "inside attached documents"? I don’t understand what you are referring to here.
        • 10152
        • 156 Posts
        Forms are validated with js before submit. Some variables in this script are set dynamically depending the value of custom system settings and lexicon values.

        This is the modx template :
        <head>
            [[...]]
            <script>
        
                message    = "[[%language_entry]]";
                min_length = [[++username_min_length]];
        
                alert ( message + "The password must be at least " + min_length + " characters long.");
        
            </script>
            [[...]]
        </head>
        


        and this is the result :
        <head>
            [[...]]
            <script>
        
                message    = "Oops, some fields are invalid !";   // <== lexicon tag was replaced
                min_length = 6;                                   // <== custom system setting was replaced
        
                alert ( message + "The password must be at least " + min_length + " characters long.");
        
            </script>
            [[...]]
        </head>
        

        That works like a charm when the js is called inline directly in the template, the lexicon entry is replaced by its value, the system setting too.

        But because it’s better to have scripts stored as files that will not pollute the html source, or even better, as a modx document, I’ve pasted the script into a new modx document and set content type = javascript and content disposition = attachment.

        Now It’s as if I had the script on a file on the server, but when opened in a text editor, I can see that only the system setting has been replaced, not the lexicon tag that remains unchanged (just the [[% ]] are removed):
        <head>
            [[...]]
            <script>
        
                message    = "language_entry";    // <== this is not good
                min_length = 6;                          
        
                alert ( message + "The password must be at least " + min_length + " characters long.");
        
            </script>
            [[...]]
        </head>
        


        I’ve tried several times with cached or uncached tags, or desactivated cache globaly.
          • 22303 MODX Staff
          • 10,725 Posts
          Content disposition should definitely not be "attachment", and if you make your JS an external file, you cannot use MODx placeholders; similarly, you cannot use data in a MODx Resource with a javascript content type unless the Snippets you call in that Resource take care of accessing the data you need. This is not the same as inline content, which is part of the same Resource being processed.
            • 10152
            • 156 Posts
            Thank you OpenGeek for the enlightment. I post here the snippet maybe someone will be happy :
            <?php
                    // Retrieves lexicon values 
                    // example : [[getLexiconEntry? &name=`username` &namespace=`school` &topic=`playgrnd`]]
                    $modx->getService('lexicon','modLexicon');  
                    $modx->lexicon->load($namespace.':'.$topic); 
                    $val = $modx->lexicon($name);  
                    return $val;
            ?>
            

              • 22303 MODX Staff
              • 10,725 Posts
              You are still confused; this should work the same as the snippet you created:
              [[%entry_name? &namespace=`namespace` &topic=`topic`