looking for help to use smarty vars in include php file

A place to make for-pay "CMS made simple" job offerings
Post Reply
pedes
Power Poster
Power Poster
Posts: 840
Joined: Tue Jan 27, 2009 11:47 am

looking for help to use smarty vars in include php file

Post by pedes »

how do i use smarty vars in an include php file ?

I have a CMSMS website where i need to use some vars in an included php file.
this UDT {get_url_data} i use on top of the template:

Code: Select all

$gCms = cmsms();

session_start(); 
error_reporting(E_ALL); 
$card_id = $_SESSION['card_id'] ;

$url = $_SERVER['REQUEST_URI'];
list($page, $lang, $subpagina) = explode("/", $url);

$smarty = &$gCms->GetSmarty();
$smarty->assign('lang', $lang);
$smarty->assign('subpagina', $subpagina);
$smarty->assign('card_id2', '$card_id');

include 'consument/lang/'.$lang.'.php';


If i put {$lang} or {$subpagina}, then i get the correct value in the content ($lang = nl and $subpagina = client), so the UDT is working.

next i use an UDT to include the php file:

Code: Select all

include ('consument/index.php'); 
the include files are located in the dir consument.
this include file is lokking for 2 things at first before going further, if there is a $card_id and if $subpagina = 'client'.
this include file looks like this:

Code: Select all

<?
if ( (!$card_id) && ($subpagina <> "client") )  { echo "$lang_nietingelogd<br><br><a href=\"javascript:history.go(-1)\"><< $lang_terug</a>" ; } else {


if (($_SESSION['user_level'] == "2") && ($subpagina <> "client")  )  { } else {


if ( ((!$card_id) && ($subpagina == "client"))  || ($_SESSION['user_level'] <> "1") ) {
		include ('consument/loginform.php');  
		} else { if ($subpagina == "client") {
		 
		$card_id = $_SESSION['card_id'] ;
		include 'consument/db.php';
		$result = mysql_query("select * from dbo_b_fidcard  where card_id = '$card_id'");
$row = mysql_fetch_assoc($result);
 
		echo "<br><br>
		$lang_welcome $row[first_name] $row[last_name], <br><br>

  <p align=\"center\"><strong>$lang_pointsbox_1</strong></p>
  <br>
    <br>
    <p align=\"center\"><a href=\"index.php/$lang/your_pass\"><img src=\"../2009/uploads/images/afbeelding.png\" width=\"150\" height=\"24\" /></a>
  </p>
" ; } } } }
?>
But like i said, the code stops on the first check, because the vars $card_id, $subpagina and $lang are not passed to the include php file.
I only get << on the screen from the first 'echo'.

How can i pass these variables to the include php file en so let the php file work.

Hope someone knows this
Kind regards
Peter
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: looking for help to use smarty vars in include php file

Post by applejack »

Why don't you just include the php code in the UDT or you will have to make the php code a function and pass the smarty values to that in the UDT.
Post Reply

Return to “Help Wanted (commercial)”