| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Add variable to homepage | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() 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!
__________________
// Ayla X-Cart 4.4.1 |
|||||||
#2
|
|||||||||
|
|||||||||
![]() 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
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#3
|
|||||||
|
|||||||
![]() 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! //
__________________
// Ayla X-Cart 4.4.1 |
|||||||
#4
|
|||||||||
|
|||||||||
![]() Use the xcart built in functions. For this - func_query(); - will return an array with the results
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#5
|
|||||||
|
|||||||
![]() So to recap (with a demo query) this is all it needs?:
Quote:
__________________
// Ayla X-Cart 4.4.1 |
|||||||
#6
|
|||||||||
|
|||||||||
![]() $products = func_query("SELECT * FROM $sql_tbl[products] ORDER BY field ASC");
$smarty->assign("new_products", $products);
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#7
|
|||||||
|
|||||||
![]() Perfect.
__________________
// Ayla X-Cart 4.4.1 |
|||||||
|
|||
X-Cart forums © 2001-2020
|