![]() |
Using a Smarty tag in PHP code
Hey all,
I'm trying to implement a rating system I found that uses PHP to display the "stars" image. Here is the code I want to put in my main/product.tpl below the Buy Now and Wishlist buttons: PHP Code:
I want to use the productid because the ratings system uses an SQL database to keep track of everything and each item needs a unique identifier. Thanks in advance for any help. |
Re: Using a Smarty tag in PHP code
I think it's more complicated than that. You have an object reference there "$rr". So that object has to be defined somewhere in the code you cut from. Then after that is resolved, there are other things you may need to do.
|
Re: Using a Smarty tag in PHP code
Using PHP in smarty can be done like this:
Code:
{php}Your PHP code here{/php} However using PHP within smarty is not recommended as it decreases performance and caching ability is reduced. You should instead create its own php file and then assign into smarty. Smarty code cant be used in php. |
Re: Using a Smarty tag in PHP code
I'm having a similar problem.
Shamum I've used the code you gave but I'm having trouble. I need to push details from Smarty tags through a PHP script when a user clicks a submit button. The way I have it at the moment is: Code:
{php}$strBillingAddress1 = "{/php}{$address.address}{php}";{php} So I want the address to show up for this field, however the result I get is: Code:
?><?php echo Array['address']['address']; ?> <?php Where am I going wrong? Any help is much appreciated :mrgreen: |
Re: Using a Smarty tag in PHP code
OK, so is there a way to have smarty generate a variable equal to the productid which can then be read by the php script?
Code:
<?php echo rating_bar('SMARTY_PRODUCTID_VARIABLE_HERE','5'); ?> In the first set of single-quotes, I want the productid (assigned by SMARTY as a variable?), the second single-quote number is how many stars show up. Or, is it possible to have the php script in this case grab the productid from the X-Cart database? |
Re: Using a Smarty tag in PHP code
Try...
Code:
Code:
|
Re: Using a Smarty tag in PHP code
Quote:
Thanks for the tip but I'm having issues getting to work. I've followed all instruction to a T and every time I put the code in the template to get the star rating to show up, I get these errors all over the page: Code:
INVALID SQL: 1046 : No database selected It seems pretty obvious it's some kind of conflict with CDSEOPro, but I have no idea where to start looking to fix it. |
Re: Using a Smarty tag in PHP code
Bump. Any have any idea about this new problem?
|
Re: Using a Smarty tag in PHP code
Most likely the code you are calling closes the DB connection that is used by X-Cart and/or CDSEO.
|
All times are GMT -8. The time now is 11:46 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.