View Single Post
  #4  
Old 07-12-2005, 08:19 AM
 
Online Michael Online Michael is offline
 

eXpert
  
Join Date: Mar 2005
Location: Melbourne, Australia
Posts: 273
 

Default

Thank you ETInteractive.com

Well, IБ─≥ve done it. Finally! I said I would share, so here it is.

What does it do I hear you ask? ThisБ─╕

This mod searches a particular category and displays the contents at random on the home page. In my case, I have a Б─°ClearanceБ─² category that I wanted to highlight. This mod works great on x-cart 4.1.13.

I should also note that this mod is based on the Б─°SpecialsБ─² mod posted by funkydunk but is, by large, different because it only focuses on one single category instead of the entire database. The mod can be configured to display any number of products (currently set to 5) and you can nominate any category you like by simply modifying the product id (currently set to Б─°278Б─²).

I should also mention that this mod will display the following product information:

Product thumbnail (25 pixels wide)
Product name
Product list price (with a line running through it)
Product price

(Note: You will have to edit the clearance.tpl file (below) if you want to add, modify, or remove any of the above information)

Here is a an image of what it looks like in my store (currently under construction and closed... sorry).

[SCREENSHOT WAS REMOVED FROM HERE]

So without further delay, this is what you need to do:

Create a file called clearance.php in the xcart root directory and paste the following code into it. Save the file (check if you have write permissions first). Keep in mind that you will need to either nominate and existing category, by replacing 278 with your own, or create a new one. You don't have to call it "Clearance"... any name will do. Also, don't forget to add some products to it too. If you want a higher or lower limit than 5 just replace the 5 with the figure you want.

Code:
<? // the database query $query = "SELECT * FROM $sql_tbl[products],$sql_tbl[products_categories],$sql_tbl[pricing] WHERE forsale='Y' AND avail>0 AND categoryid=278 AND $sql_tbl[products_categories].productid=$sql_tbl[products].productid AND $sql_tbl[products].productid=$sql_tbl[pricing].productid ORDER BY RAND() LIMIT 5 "; // give the product array to smarty to make it available sitewide. $clearance = func_query($query); $smarty->assign("clearance",$clearance); ?>
Now add the following line to your home.php file (once again, check you write permissions):
Code:
require $xcart_dir."/clearance.php";

Just after this:
Code:
define('OFFERS_DONT_SHOW_NEW',1); require "./auth.php";

Now, in you welcome.tpl (or where ever else you want this mod to show) add the following code:
Code:
{include file="customer/main/clearance.tpl"}

Now, somewhere in the middle, add the following code to the skin1/customer/home_main.tpl file:
Code:
{elseif $main eq "clearance"} {include file="customer/main/welcome.tpl"}

Now create a file called clearance.tpl in skin1/customer/main directory and paste the following code into it:
Code:
{* $Id: clearance.tpl,v 1.3.2.1 2004/11/16 11:15:01 max Exp $ *} {if $clearance ne ""} {capture name=clearance_list} <TABLE cellpadding="0" cellspacing="2" border="0"> {section name=num loop=$clearance} <TR> <TD width="30"> {include file="product_thumbnail.tpl" productid=$clearance[num].productid image_x=25 product=$clearance[num].product} </TD> <TD> {$clearance[num].product} <S>{include file="currency.tpl" value=$clearance[num].list_price}</S> Now:{include file="currency.tpl" value=$clearance[num].price} </TD> </TR> {/section} </TABLE> {/capture} {include file="dialog.tpl" title= "Clearance Items" content=$smarty.capture.clearance_list extra="width=100%"} {/if}
That's it! Enjoy!
__________________
X-Cart 5.3.5.4
Reply With Quote