Okay
I'm working on a small project with some bespoke elements and one was to add a block that listed the last 4 new products the same as the featured block when using the multi column format.
So, looking at the system it didn't provide such a feature but it did provide the 'Featured Block', so I decided to replicate the code and add some tweaks to get it to work showing the latest products as a new block.
Having looked around the forum, it would seem a few have wanted this but either ended up buying in a bolt on or not getting resolved.
So.......
1. Create a new .php file in a text editor call it latest_products.php and put in web root.
Place in it.....
PHP Code:
if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); }
/**
* Select from products table
*/
$user_account['membershipid'] = max(0, intval($user_account['membershipid']));
$old_search_data = @$search_data['products'];
if (!empty($mode)) {
$old_mode = $mode;
}
/**
* latest products are shown without pagging navigation
*/
$do_not_use_navigation = false;
$search_data['products'] = array();
$search_data['products']['forsale'] = 'Y';
$search_data['products']['sort_condition'] = "$sql_tbl[products].productid DESC";
$objects_per_page = 4; /* how many products do you want listed */
$search_data['products']['_']['inner_joins']['products_categories'] = array(
'on' => "$sql_tbl[products].productid=$sql_tbl[products_categories].productid AND $sql_tbl[products_categories].avail='Y' AND $sql_tbl[products_categories].categoryid='" . intval($cat) . "'");
$REQUEST_METHOD = 'GET';
$mode = 'search';
include $xcart_dir . '/include/search.php';
$search_data['products'] = $old_search_data;
if (isset($old_mode)) {
$mode = $old_mode;
}
unset($old_search_data, $old_mode);
if (!empty($active_modules['Subscriptions'])) {
include $xcart_dir . '/modules/Subscriptions/subscription.php';
}
$do_not_use_navigation = false;
if ($total_items > 0) {
$smarty->assign('l_products', $l_products);
}
?>
2. in home.php around line 126 add below featured_products req the additional one for latest_products.
PHP Code:
include './featured_products.php';
// Mod for latest products
include './latest_products.php';
3. In home_main.tpl line 66 include the l_products=$l_products behind the f_products (/skin/common_files/customer/home_main.tpl)
Quote:
{include file="customer/main/welcome.tpl" f_products=$f_products l_products=$l_products}
|
4. Now we create copies of the featured templates and modify them
template 1 called "latest2.tpl"
Quote:
{*
$Id: latest2.tpl,v 1.1 2010/05/21 08:32:04 joy Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{if $products ne ""}
{capture name=dialog}
{include file="customer/main/latesthp.tpl" $products=$l_products}
{/capture}
{include file="customer/dialog.tpl" title=$lng.lbl_latest content=$smarty.capture.dialog sort=true additional_class="products-dialog dialog-featured-list" sort=false}
{/if}
|
template 2 called latesthp.tpl
Quote:
{*
$Id: latesthp.tpl,v 1.4 2010/07/14 05:35:30 igoryan Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{if $products}
{if $config.General.ajax_add2cart eq 'Y' and $config.General.redirect_to_cart ne 'Y'}
{include file="customer/ajax.add2cart.tpl" _include_once=1}
{/if}
{if $active_modules.Customer_Reviews and $config.Customer_Reviews.ajax_rating eq 'Y'}
{include file="modules/Customer_Reviews/ajax.rating.tpl" _include_once=1}
{/if}
{if $active_modules.Feature_Comparison and not $printable and $products_has_fclasses}
{include file="modules/Feature_Comparison/compare_selected_button.tpl"}
{/if}
{if $config.Appearance.products_per_row gt 1 and ($featured eq "Y" or $config.Appearance.featured_only_multicolumn eq "N")}
{include file="customer/main/products_t.tpl"}
{else}
{include file="customer/main/products_t.tpl"}
{/if}
{if $active_modules.Feature_Comparison and not $printable and $products_has_fclasses}
{include file="modules/Feature_Comparison/compare_selected_button.tpl"}
{/if}
{/if}
|
These both go into /skin/common_files/customer/main/ directory
5. Finally the welcome template /skin/common_files/customer/main/welcome.tpl
add in the new template under the featured.....
Quote:
{include file="customer/main/featured.tpl"}
{include file="customer/main/latest2.tpl" l_products=$l_products}
|
All should be done and if like mine looks like the attachment.