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
    That’s right. The chunk is evaluated and its content put in the snippet’s parameter value. So the snippet is still stuck at the =.
      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
      • 33372
      • 1,611 Posts
      Quote from: sottwell at Sep 07, 2010, 03:21 AM

      That’s right. The chunk is evaluated and its content put in the snippet’s parameter value. So the snippet is still stuck at the =.
      You can pass just the chunk name as a snippet parameter (without the {{...}}) and then use $modx->getChunk($chunkName); inside the snippet and avoid that problem.
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 19975
        • 429 Posts
        SandersDesign Reply #13, 16 years ago
        I’ve added the finial touches to the code:

        <?php
        /* Example snippet	: [!langGet? &outputKer=`text here` &outputEng=`text here` &outputBilingual=`text here`!]
         * &outputKer 		: output for Cornish titles
         * &outputEng 		: output for English titles
         * &outputBilingual 	: output for bilingual titles 
         *
         * Example snippet	: [!langGet? &titleKer=`pagetitle` &titleEng=`description !]
         * &titleKer 			: MODx document varible for Cornish, use MODx varible names
         * &titleEng 			: MODx document varible for English, use MODx varible names
         *
         * Example snippet	: [!langGet? &chunkKerTpl=`chunk-name` &chunkEngTpl=`chunk-name` !]
         * &chunkKerTpl		: chunk used to show Cornish
         * &chunkEngTpl		: chunk used to show English
         */
         
        $language = (isset($_GET['lang'])) ? $_GET['lang'] : (isset($_COOKIE['lang']) ? $_COOKIE['lang'] : 'eng');
        $output='';
        
        switch ($language){
        	case 'ker':
        		if(isset($chunkKerTpl)){
        			$output=$modx->getChunk($chunkKerTpl); // Show only chunk if set 
        		} elseif (isset($titleKer)) {
        			$output=$modx->documentObject[$titleKer]; // Show title if set
        		} else {
        			$output=(isset($outputKer) ? $outputKer : ''); // Show output if if exists
        		};
        		setcookie ('lang', 'ker');
        		break;
        	case 'eng':
        		if(isset($chunkEngTpl)){
        			$output=$modx->getChunk($chunkEngTpl); // Show chunk if set
        		} elseif (isset($titleEng)) {
        			$output=$modx->documentObject[$titleEng]; // Show title if set
        		} else {
        			$output=(isset($outputEng) ? $outputEng : '');  // Show output if it exists
        		};
        		setcookie ('lang', 'eng');
        		break;
        	default:
        			if(isset($outputBilingual)) {
        				$output=$outputBilingual;
        			} elseif ((isset($chunkKerTpl)) && (isset($chunkEngTpl))) {
        				$output=$modx->getChunk($chunkEngTpl) . $modx->getChunk($chunkKerTpl); // Show only chunks if they are set 
        			} elseif ($_COOKIE['lang'] == "ker") {
        				(isset($chunkKerTpl)) ? $output=$modx->getChunk($chunkKerTpl) : (isset($titleKer)) ? $output=$modx->documentObject[$titleKer] : (isset($outputKer)) ? $output=$outputKer : '';  // Show values for Cornish if set 
        			} else {
        				(isset($chunkEngTpl)) ? $output=$modx->getChunk($chunkEngTpl) : (isset($titleEng)) ? $output=$modx->documentObject[$titleEng] : (isset($outputEng)) ? $output=$outputEng : '';  // Show values for English if set 
        			};
        	};
        return $output;
        ?>


        Thanks for all the suggestions
          Martin Sanders - Design & Web Development