| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Random Image or Random Products - Category Specific | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
![]() Ok, I have been reading through all the threads concerning random images and it seems that over time there has been a request for that and/or random products - so here is a freebie.
This Mod searches the product database for products that are relevant to the current situation. This means that it is not only category specific but also user or membership specific. It will pick preset number of products in random order. This number is set within Admin under General Settings -> Modules Options. There is also a template that will take the number of random products returned and pick one to display a random product image. This image is also linked to the product page for that product. INSTALL INSTRUCTONS: Within Patch/Upgrade section of X-Cart or within SQL Admin run this query: Code:
Next create a new directory under /modules/ named "Random_Products" and a directory under /skin1/modules/ named "Random_Products". Within /modules/Random_Products create a file named "random.php" with this content: Code:
Next create two files under /skin1/modules/Random_Products/ named "random.tpl" and "random_image.tpl" with the contents as: random.tpl Code:
random_image.tpl Code:
Now, edit your home.php file in root directory and add the following lines under the section that loads the Best Sellers module: Code:
** New Step ** This is a new step that you will need to do to make the single random image work on most systems (since that code is using a PHP modifier and not a Smarty modifier). If the single random image is working for you already then you do not need to perform this step. Open the file /Smarty-2.x.x/Smarty.class.php for editing. On or around line 234 you will see the code: Code:
This need to be change to read Code:
Now, where ever you want to display random products, just add this code in the template Code:
Code:
The template that displays the random products feeds into the template that you are using to display the product listings site wide. So, if you have your store set to display products 3 per row, then the random products will also display that way. The initial settings in Admin are that the module is enabled and the number of random products are 3. You can disable the module at the same location that all other modules are enabled or disabled. If you find this Mod useful, donations are welcome ![]() |
|||||||||
#2
|
|||||||
|
|||||||
![]() Nice one
![]()
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#3
|
|||||||
|
|||||||
![]() Hi, I get this error. What is it?
Code:
__________________
X Cart Gold Ver. 4.1.6 |
|||||||
#4
|
|||||||||
|
|||||||||
![]() OK - well - I guess I need to rewrite that query (or the template that is used to display the products). It seems that the function "func_search_products" does not load up the minimum and low-stock ammounts (among other things).
Those errors are part of the math functions in the product templates and the buy-now button template. |
|||||||||
#5
|
|||||||
|
|||||||
![]() This was exactly what I wanted...but it doesn't appear to be working for me either, although I don't get the error that micromedia gets. I added the referencing code:
Code:
to skin1/customer/main/product.tpl, but all that shows up is a box with a yellow border - here's a sample page http://www.vidaville.com/store/product.php?productid=250&cat=1&page=1. You'll see the empty box near the bottom of the page below the area called "You may also like...". What I want to be able to do is only show products from certain categories within that area. Is that the goal of this mod? I thought it was, but I could be wrong. ![]() Thanks! |
|||||||
#6
|
|||||||||
|
|||||||||
![]() Actually the goal was to display within a category listing not necessarily on the product page. This is a consideration though. I will see if I can change that to make it work that way.
|
|||||||||
#7
|
|||||||||
|
|||||||||
![]() Same error message with smarty and x/y here
![]()
__________________
Radek Karban - WebDesign - Reklama.cz (not x-cart site) several x-cart (gold version 4.0.10 - 4.1.3, linux debian) and a huge pack of mods ![]() |
|||||||||
#8
|
|||||||||
|
|||||||||
![]() I have made a small change to the random.php file that will clear up some issues that some people are having - specifically the issue of not getting an error message, but not getting any images either.
I have also added an extra step that you may need to do if the single random image is not working for you. |
|||||||||
#9
|
|||||||||
|
|||||||||
![]() The random products are working great.
Thanks for this great mod.
__________________
Best regards, Niki Buitenrust Hettema X-Cart Gold 4.1.8 (Live & Loaded) Royal Bhaktapur: Handmade products from Nepal - Pashmina's, scarfs, shawls, stola's and more... |
|||||||||
#10
|
|||||||||
|
|||||||||
![]() Got a question about the random images. Is it also possible to include the product title above the random image? And maybe the product price. That would be very nice.
__________________
Best regards, Niki Buitenrust Hettema X-Cart Gold 4.1.8 (Live & Loaded) Royal Bhaktapur: Handmade products from Nepal - Pashmina's, scarfs, shawls, stola's and more... |
|||||||||
|
|||
X-Cart forums © 2001-2020
|