MySQL query in smarty template
Is it possible to run a MySQL query and assign the value to a variable directly within a smarty template file? I cannot seem to find any info on this.
|
Re: MySQL query in smarty template
You can use {php} php code here / assign variable to smarty {/php} but I wouldn't recommend this. Do it directly in the php file instead
|
Re: MySQL query in smarty template
Thanks.
If that is the case, how would I do so for template(s) I created? What I am trying to accomplish: - when a user clicks on a main category link in the top horizontal bar, the left bar menu will display the sub categories for that category. I have been able to do this using {if $categories} in left_bar.tpl - then when the user clicks a sub-menu link from the left bar, I need to have the sub categories listed again, but with the products for that category listed below it. This is where I thought I would use the MySQL query below to retrieve the sub categories and $cat_products to list the products below the current sub category. Code:
SELECT categoryid FROM xcart_categories WHERE parentid = {$current_category.parentid} ORDER BY categoryid ASC ## Left bar ## Code:
{if $categories} preview so far: http://64.64.19.63/~sklz/newsite/store/Baseball/ |
Re: MySQL query in smarty template
Quote:
PHP Code:
Code:
{foreach from=$sub_categories_nav item=subcat name=subcategories_nav} |
All times are GMT -8. The time now is 03:47 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.