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)
-   -   $Smarty assign won't parse (https://forum.x-cart.com/showthread.php?t=2106)

lesmckeown 04-01-2003 02:30 AM

$Smarty assign won't parse
 
Hi folks -

I have a simple sql query I want to run conditionally in my product.tpl [depending on which product is selected]. It accesses an added mysql table containing additional product info.

I have written a small script, workshops.php, which I put in store/customer/, like this:

Code:

<?

require "../smarty.php";
require "../config.php";


$workshop_dates = func_query("select * from $sql_tbl[workshop_dates]");


$smarty->assign("workshopdates",$workshop_dates);
$smarty->display('workshops.tpl');


?>


The file mentioned in the last line, 'workshops.tpl', is in [skin1]/customer/main, and looks like this:

Code:


<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr><td colspan=2><font class=ProductDetailsTitle>{$lng.lbl_workshop_dates}</font></td></tr>
<tr><td class=Line height="1" colspan=3>[img]{$ImagesDir}/orangespacer.gif[/img]</td></tr>
<tr><td colspan=2></td></tr>

<tr class=TableHead> 

<td width="35%">Dates</td>
<td>Availability</td>
<td>Check to Register</td>
<tr><td colspan=3></td></tr>

{section name=workshopdates loop=$workshopdates}
<tr > 
<td width="35%">{$workshopdates.dates}</td>
<td>Availability</td>
<td>Check to Register</td>
<tr><td colspan=3></td></tr>
{/section}
<tr><td colspan=3></td></tr>
</tr>
</table>


Finally, I have an {if} statement in [skin1]/customer/main/product.tpl:
Code:


{if...etc}
{include file="../customer/workshops.php"}
{/if}


The problem is, no matter how I try to configure it, products.tpl chokes at the line beginning '$smarty->assign...' when parsing workshops.php.

It renders everything after the first '$smarty->' [ie from the word 'assign...' onward] in the browser as text, and the include of workshops.tpl doesn't happen.

Any idea where I've gone wrong?

All suggestions greatly appreciated!

Cheers

Les

Alan 04-01-2003 02:54 AM

Hello friend,

I believe that you cannot include .php files in a smarty include statement. You will have to get around that it by requiring the file in product.php using
Code:

require "./workshops.php"
NOTE: only if your workshops.php is saved under /yourxcart/customer/

Alter your if/else statement to fit .php style, or private message me with your if else statement and what you would like to do with it if you would like. (gramma alert! T_T)


All times are GMT -8. The time now is 08:56 PM.

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