Jump to content

smarty and php


nbbcj

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/267202-smarty-and-php/
Share on other sites

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

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/267202-smarty-and-php/#findComment-1370359
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/267202-smarty-and-php/#findComment-1370409
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.