Author Topic: [SOLVED]Import variable into the template  (Read 1691 times)

krakoukass

  • Beginner
  • *
  • Posts: 38
[SOLVED]Import variable into the template
« 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 !




krakoukass

  • Beginner
  • *
  • Posts: 38
Re: [SOLVED]Import variable into the template
« Reply #1 on: August 27, 2010, 12:09:04 pm »