X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Problems passing PHP variables to Smarty templates (https://forum.x-cart.com/showthread.php?t=5864)

NuAlpha 01-05-2004 02:37 PM

Problems passing PHP variables to Smarty templates
 
I have created the file "query_parse.php" in the customer directory. Inside that file is the following:
Code:

<?PHP
$arg_value = explode("=", $_SERVER['QUERY_STRING']);
$smarty = new Smarty;
$smarty->assign("argval", $arg_value[1]); // value of the URL argument
?>


I am trying to display certain tabs at the top of my site by using the category of the product being displayed using the following code in head.tpl:

Code:

{ include_php file="../customer/query_parse.php" }
{ if $argval eq "" }
        { include file="topnavtabs/top_nav_tabs_01.tpl" }
{ elseif $argval eq "3" }
        { include file="topnavtabs/top_nav_tabs_02.tpl" }
{/if}


Every time I now try to load my site I always receive the error "Fatal error: Call to a member function on a non-object in query_parse.php on line 3".

The variable churns out the correct number each time if I remove the "smarty->assign" line and replace that with a "print($arg_value)", so I know that I am getting the information I need. I just can't get it into the template I am using.

I have going over and over documentation of PHP and Smarty for the last 4 hours and am at my wits end to explain why I can't pass this variable. I am new to both PHP and Smarty so please bare with me.

Thanks,
Joshua :(

NOTE: I moved this post from the board "Program Logic" today, this was originally posted on January 4th.

NuAlpha 01-05-2004 02:43 PM

Somehow, and for no apparent reason, the problem has stopped giving me the "non-object" error after I 'required' the Smarty.class.php, but any attempt to reload my pages after a change in the template says I can't redeclare a certain variable (sorry, forget name).

Also, I still cannot get variables created in a PHP document to pass into a Smarty template. Any PHP variables or Smarty variables created in a PHP document always contain nothing when inside a template. Variables I assign in a template also don't hold their data no matter what I put in them using the syntax ->
Code:

{assign var="foo" value="bar"}

This is most frustrating. :x

If anyone can please enlighten me as to what is going on I would appreciate it.


All times are GMT -8. The time now is 09:37 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.