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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.