nbbcj Posted August 17, 2012 Share Posted August 17, 2012 hay all, im not sure if im right to post here as this is a smarty and php question, but here goes. i have this bit of code in a .tpl file {include file="$template/inc/$pagetitle.tpl"} <<< this is smarty tag {php} $q1= strpos($_GET['action'], "products"); if($q1!== false) { echo '<h2>My Products & Services</h2><p> These are all the services you have registered in this account.</p>'; } $pos = strpos($_GET['action'], "domains"); if($q1!== false) { echo '<h2>My Domains</h2><p> View & manage all the domains you have registered with us from here...</p>'; } {/php} what im trying to do is if the url is somefile.php then include the smarty tag but if the url is somefile.php?action=products then run the if code. at the min if the url is somefile.php?action=products the page shows the include and the if code any help please thanks in advance kaine Quote Link to comment Share on other sites More sharing options...
scootstah Posted August 17, 2012 Share Posted August 17, 2012 That really shouldn't be in a template file. You're using Smarty, which means you have an exceedingly easy way to separate application logic from presentation logic. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 17, 2012 Share Posted August 17, 2012 Yeah, those should be two separate .tpls. Have your PHP file with basically the same logic, but determine which .tpl to use. Quote Link to comment Share on other sites More sharing options...
nbbcj Posted August 18, 2012 Author Share Posted August 18, 2012 Hi thank you for your reply and sorry about the delay in getting back to you. im new to smarty i am going to split the code in to 2 tpl's, just for ease of coding i stuck it all in. so im thinking file1.tpl has this {include file="$template/inc/$pagetitle.tpl"} <<< this is smarty tag and file2.tpl has this {php} $q1= strpos($_GET['action'], "products"); if($q1!== false) { echo '<h2>My Products & Services</h2><p> These are all the services you have registered in this account.</p>'; } $q1 = strpos($_GET['action'], "domains"); if($q1!== false) { echo '<h2>My Domains</h2><p> View & manage all the domains you have registered with us from here...</p>'; } {/php} then in the main tpl file that did hold the above code will now have some thing like this {php} if($_GET['action'] !== false) { {include file="$template/inc/file1.tpl"} } else{ {include file="$template/inc/file2.tpl"} } {/php} Sub question does if($_GET['action'] !== false) mean if action is not in the url then run {include file="$template/inc/file1.tpl"} or will it just look for ?action=false in the url. im a bit noobish and have jumped in right at the deep end trying to custom a WHMCS script. thanks for any help you can provide Quote Link to comment Share on other sites More sharing options...
nbbcj Posted August 18, 2012 Author Share Posted August 18, 2012 Any help any body ?? Hi thank you for your reply and sorry about the delay in getting back to you. im new to smarty i am going to split the code in to 2 tpl's, just for ease of coding i stuck it all in. so im thinking file1.tpl has this {include file="$template/inc/$pagetitle.tpl"} <<< this is smarty tag and file2.tpl has this {php} $q1= strpos($_GET['action'], "products"); if($q1!== false) { echo '<h2>My Products & Services</h2><p> These are all the services you have registered in this account.</p>'; } $q1 = strpos($_GET['action'], "domains"); if($q1!== false) { echo '<h2>My Domains</h2><p> View & manage all the domains you have registered with us from here...</p>'; } {/php} then in the main tpl file that did hold the above code will now have some thing like this {php} if($_GET['action'] !== false) { {include file="$template/inc/file1.tpl"} } else{ {include file="$template/inc/file2.tpl"} } {/php} Sub question does if($_GET['action'] !== false) mean if action is not in the url then run {include file="$template/inc/file1.tpl"} or will it just look for ?action=false in the url. im a bit noobish and have jumped in right at the deep end trying to custom a WHMCS script. thanks for any help you can provide 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.