![]() |
Add variable to homepage
I'm totally new to X-Cart but have a great deal of PHP/HTML experience.
I am trying to write some custom code to display products on the homepage (there are very few products in this store) and I have set up the debug window to show includes AND variables... but I don't seem to have access to the $products variable from the homepage. How can I add the products array variable to the homepage so I can loop through them? Or rather where can you set which var's are available on each page? (in case there are other pages I need to tweak) Many thanks! |
Re: Add variable to homepage
In the php file showing the page in question. You have to assign it as smarty variable. To customize xcart you will need not only php but also smarty knowledge - www.smarty.net
In general for your question you can do this $products = "sql query to get the products array"; $smarty->assign("new_products", $products); which will give you $new_products array available for that page |
Re: Add variable to homepage
Thank you! That is exactly what I was looking for. In reference to the line below, does it just need a SQL query or the returned results from mysql_query()?
Quote:
Thanks for your help! // |
Re: Add variable to homepage
Use the xcart built in functions. For this - func_query(); - will return an array with the results
|
Re: Add variable to homepage
So to recap (with a demo query) this is all it needs?:
Quote:
|
Re: Add variable to homepage
$products = func_query("SELECT * FROM $sql_tbl[products] ORDER BY field ASC");
$smarty->assign("new_products", $products); |
Re: Add variable to homepage
Perfect.
|
All times are GMT -8. The time now is 07:45 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.