JelleG Posted September 20, 2016 Share Posted September 20, 2016 I want to check if my currenty URL contains some value. Therefore I use the following code, but that does not work. {if $smarty.server.HTTP_REFERER|strstr:'domain=transfer&sld='} The full URL; https://example.com/cart.php?a=add&domain=transfer&sld=value&tld=.com What am I missing? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 20, 2016 Share Posted September 20, 2016 they'd be a few ways to do it - depending on where you are wanting to add the code... the best way would likely be to use GET, so the following should work... {if $smarty.get.domain eq 'transfer'} that will effectively check for 'domain=transfer' in the URL... but you could string multiple queries together if you wanted to be more specific... {if $smarty.get.domain eq 'transfer' and $smarty.get.sld eq 'value'} or you could see if an existing variable contains your string... {if $currentpagelinkback|strstr:'domain=transfer&sld='} ... but using GET should be your first choice where possible. 0 Quote Link to comment Share on other sites More sharing options...
JelleG Posted September 20, 2016 Author Share Posted September 20, 2016 they'd be a few ways to do it - depending on where you are wanting to add the code... the best way would likely be to use GET, so the following should work... {if $smarty.get.domain eq 'transfer'} that will effectively check for 'domain=transfer' in the URL... but you could string multiple queries together if you wanted to be more specific... {if $smarty.get.domain eq 'transfer' and $smarty.get.sld eq 'value'} Amazing, thanks a lot!! But I want to check if the URL contains 'transfer' and also if there is a 'sld' with some value. Because the sld is dynamic, the second rule does not work, because the 'value' is dynamic. Is this also possible using the GET? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 20, 2016 Share Posted September 20, 2016 Amazing, thanks a lot!!But I want to check if the URL contains 'transfer' and also if there is a 'sld' with some value. Because the sld is dynamic, the second rule does not work, because the 'value' is dynamic. Is this also possible using the GET? just check to see if the variable exists... {if $smarty.get.domain eq 'transfer' and $smarty.get.sld} so using your URL above, the if statement should be true and work... if you change the URL to 'cart.php?a=add&domain=transfer&tld=.com', then it should fail. 0 Quote Link to comment Share on other sites More sharing options...
JelleG Posted September 20, 2016 Author Share Posted September 20, 2016 just check to see if the variable exists... {if $smarty.get.domain eq 'transfer' and $smarty.get.sld} so using your URL above, the if statement should be true and work... if you change the URL to 'cart.php?a=add&domain=transfer&tld=.com', then it should fail. Thanks that works well! The only thing is, I want to use that line also in the domainoptions.tpl file, but that does not seem to work. Than the code {if $smarty.get.domain eq 'transfer' and $smarty.get.sld} does not work. How can I solve that? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 20, 2016 Share Posted September 20, 2016 by the time you get to domainoptions, you'll lose access to those GET variables, but they'd almost certainly still exist under another name - you could try... {if $checktype eq 'transfer' and $domain} it really depends what you want to do with these values - but the above should tell you if it's a transfer or not. 0 Quote Link to comment Share on other sites More sharing options...
JelleG Posted September 20, 2016 Author Share Posted September 20, 2016 by the time you get to domainoptions, you'll lose access to those GET variables, but they'd almost certainly still exist under another name - you could try... {if $checktype eq 'transfer' and $domain} it really depends what you want to do with these values - but the above should tell you if it's a transfer or not. Thanks! But I also need to check if there is a sld in the URL. I want to add a script, to auto clicks the transfer button when there is 'transfer' and a 'sld' in the URL. Because this means that from outside our WHMCS the check is done that the domain can be transfered and I then want to auto click the transfer button. But this should not happen when someone is checking a domain in the WHMCS cart. So is it possible inside the domainoptions.tpl to check if the URL contains 'transfer' and 'sld'? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 20, 2016 Share Posted September 20, 2016 But this should not happen when someone is checking a domain in the WHMCS cart.So is it possible inside the domainoptions.tpl to check if the URL contains 'transfer' and 'sld'? then we've come full circle - go back to a slightly modified version of your original code and it should work fine... {if $smarty.server.HTTP_REFERER|strstr:'domain=transfer&sld='} so if you follow your URL, the above should work... if you're just going through the cart normally, SLD won't be in the URL, so it shouldn't trigger. 0 Quote Link to comment Share on other sites More sharing options...
JelleG Posted September 20, 2016 Author Share Posted September 20, 2016 then we've come full circle - go back to a slightly modified version of your original code and it should work fine... {if $smarty.server.HTTP_REFERER|strstr:'domain=transfer&sld='} so if you follow your URL, the above should work... if you're just going through the cart normally, SLD won't be in the URL, so it shouldn't trigger. That did the trick, amazing! Thanks 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.