We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19889
    • 616 Posts
    Hello
    the following code produces kind of a weird result:
    // language is not set
    if (!isset($lang)) {
    	// get language from language container - tv is @INHERIT
    	$tv  	 = $modx->getTemplateVarOutput(array('tv-lang'), $modx->documentIdentifier);
    	$lang = $tv['tv-lang'];
    }
    
    if (!isset($box)) return '';
    
    /*if ($lang == 'de') {
    	$id = 14;	
    } elseif ($lang == 'en') {
    	$id = 91;	
    } elseif ($lang == 'fr') {
    	$id = 92;	
    } else  {
    $id = 'error';
    }*/
    
    switch ($test) {
    case 'de':
        $id = 14;
        break;
    case 'en':
        $id = 91;
        break;
    case 'fr':
        $id = 92;
        break;
    }
    
    return 'Values: ' . $id . ' || ' . $lang . ' || ' . $modx->documentIdentifier;
    //return "[!WebLogin? &tpl=`tpl-login-".$lang."`&loginhomeid=`".$id."`&logouthomeid=`".$id."`!]";
    


    neither the if/elseif nor the switch stuff works - I’m not getting a valid id back; However, on my page, the $lang variable return e.g. ’de’.

    Hope somebody could please tell me what I’m doing wrong!?

    Thank you in advance for your input.
      • 19889
      • 616 Posts
      it’s really weird - I’m basically able to output the value of $lang to my page but don’t seem to be able to use it in the script:

      the snippet in discussion is called from a chunk like this:
      [[Sidebox?&box=`login`&lang=`[*tv-lang*]`]]


      I don’t get it.

      figured it out - the call needs to be unchached!!!

      sorry for bothering you guys.