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

    I have used Evolution several times and really liked it. This is the first time, I am using Revolution, and am finding it to be a big learning curve.

    Creating a multi-lingual site with the following snippet and a TV worked great in 1.0.4

    <?php
    // get languages info
    $tv = $modx->getTemplateVar(’languages’, "", $modx->documentIdentifier);
    $languages = $tv[’value’];

    if (!strlen($languages))
    {
    return "";
    }

    $langnames = array(
    "en" => "English",
    "se" => "svenska"
    );

    $output = "";

    // get entries in languages list
    $entries = explode(",", $languages);
    // loop through language entries
    for ($e = 0; $e < count($entries); $e++)
    {
    // seperate into lang code and target document id
    list($lang, $targetid) = explode("=", $entries[$e]);
    $text = "$langnames[$lang]";
    if (strlen($output))
    {
    $output .= ’ ’;
    }
    $output .= ’<a href="’.$modx->makeUrl($targetid).’">’.$text.’</a>’;
    }

    return $output;
    ?>
    ?>


    But now, in Revolution, I am having major issues finding a somewhat simple solution to create a small bilingual site. I am getting very frustrated at the complicated solutions to something I once found quite simple.

    Can anyone offer me some advice or place me in the right direction?

    I am not a programmer, but more of a designer, so I need real step by step tutorial.

    Or would it be wiser just to go back to Evolution? I think it is better to get on with the newer versions, but perhaps it is just above my head.

    Thanks in advance for your responses.

      • 29076
      • 615 Posts
      I have used this method my self, with only two languages. But with this method you actually have to know the ID of the other document (resource, Revo), and you have to type it in manually. So, in my case I now just use the IF-snippet: [[!If TV=empty, do not show, othervise =`<a href="[[~[[*TV-ID-of-the-other-resource]]]]"><image src="language-flag-file" /></a>`]]. smiley
        I think, thererfor I am! But what I am, and why...?
        • 16905
        • 46 Posts
        Thanks Sylvaticus,

        But how and where would I put this? I am a novice.

        Thanks in advance for you response...
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          You could put that in the template, although I don’t think that’s an actual code snippet.

          I’d guess your site structure would need to look like this:
          - English site
          -- Homepage
          -- Blog
          --- Article 1
          --- Article 2
          -- Contact
          - German site
          -- Hauptseite
          -- Etwas interessants
          --- Ersten artikel
          --- Zweiten artikel
          -- Kontact
          etc

          I think that snippet of code uses two templates (at least), one for every language. You make the template variable in which you put the ID of the translated resource (under the different resource) and then you use something like Sylvaticus posted.

          Something like this should work, assuming you named your TV "translatedResourceId":
          [[*translatedResourceId:notempty=`<a href="[[~[[*translatedResourceId]]]]" title="View in other language">View in other language</a>`]]



          There are, arguably, better solutions available, however this may be the easiest one.

          Most other solutions probably involve contexts, and I find them quite daunting to start with.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 36624
            • 535 Posts
            a plugin for the context switch : you should look here : http://modxcms.com/forums/index.php/topic,57691.0.html

            for managing multi language you should look at the Babel v2 plugin. http://modxcms.com/extras/package/?package=781 or via Package Management.
              CTRL+SHIFT+U - Clear Cache
              CTRL+SHIFT+H - Hiding Heft Panel
              CTRL+SHIFT+N - Fast Create Resource
              CTRL+ALT+P - Preview Recource (in edit resorce window)
              CTRL+ALT+S - Save