<![CDATA[ Simple if statment in code snippet won't work - My Forums]]> https://forums.modx.com/thread/?thread=104460 <![CDATA[Simple if statment in code snippet won't work]]> https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561889
I have some code, which works on a normal php page. The code snippet created will find the $_GET['retval2'] but no if statements work in the snippet, it defaults to the else.

myurl.com?retval2=survey

<?php
if($_GET['retval2'] == 'survey') { 
    $url = './BLOBSurveyVerify.php';
} else { 
   $url = './BLOBFSBMemberVerification.php';
}

echo $url;


using snippet

[[quoteSurvey]]
]]>
gavmodder Oct 03, 2018, 12:01 PM https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561889
<![CDATA[Re: Simple if statment in code snippet won't work]]> https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561957 Quote from: gavmodder at Oct 03, 2018, 12:01 PM
Hi,

using snippet

[[quoteSurvey]]

Unless it is just a typo in your forum post, the snippet should be preceded by an exclamation mark.

[[!quoteSurvey]]
]]>
andytough Oct 06, 2018, 10:57 AM https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561957
<![CDATA[Re: Simple if statment in code snippet won't work]]> https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561949 BobRay Oct 06, 2018, 03:52 AM https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561949 <![CDATA[Re: Simple if statment in code snippet won't work]]> https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561939 Quote from: treigh at Oct 03, 2018, 02:25 PM
Try
return $url;
instead

Also, try calling the snippet uncached (by placing an '!' at the beginning), e.g. [[!quoteSurvey]]]]>
jimf3000 Oct 05, 2018, 05:00 PM https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561939
<![CDATA[Re: Simple if statment in code snippet won't work]]> https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561893
return $url;
instead]]>
treigh Oct 03, 2018, 02:25 PM https://forums.modx.com/thread/104460/simple-if-statment-in-code-snippet-won-t-work#dis-post-561893