VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Products, Prices, Tax and Categories VM 1.1 => Topic started by: krakoukass on August 25, 2010, 17:22:42 pm

Title: [SOLVED]Import variable into the template
Post by: krakoukass on August 25, 2010, 17:22:42 pm
Hello everybody ! I'm reading the Developper Manual but I've a problem to understand the page 15-16.
I would like display "Call us for the price" if the visitor is not logged and if the price = 0 for shopper_group=default. It's ok if the product has only one price. If it has other price for other group, the 0 displays.
Then I would like to change the code "echo $product_price" by "echo if $product_price != 0 and shopper_group_id !>5 echo $product_price else echo Call us for price"
It's not working. It seems it's because the variable shopper_group_id isn't predefined in the templates.

P.15 in the manual, he says that I must create a template object, Import variable into the template, and parse the template.
Can you say me if I must do that in browse_1.php (if it's my template) ?

Then, at the place of "echo $product_price" I do that  :
Code: [Select]
<div class="browsePriceContainer">
    
<?php
//create a template object//
$tpl vmTemplate::getInstance();
//importing a variable into the template//
(line 19$tpl->set("shopper_group_id",$db_browse->f("shopper_group_id"));
//parse the template//
$contents $tpl->fetch'browse/browse_1.php' );
//displaying in the front-end//
if ($product_price !="0" && $shopper_group_id !="5"
   {echo 
$product_price;}
else if (
$product_price == "0"){echo "Call for price" ;} ?>
>

It's not working. i've this error :
Fatal error: Call to a member function f() on a non-object in C:\xampplite\htdocs\my_site\com_virtuemart\themes\default\templates\browse\browse_1.php on line 19

Can you help me ?

Thanks a lot !



Title: Re: [SOLVED]Import variable into the template
Post by: krakoukass on August 27, 2010, 12:09:04 pm
You can see my solution here : http://forum.virtuemart.net/index.php?topic=75182.msg249690#msg249690