Here is how I converted to a consistent layout...my 2 cents worth.
This code also provides a way to search and display products by price range, in addition to all, new, and featured products for the current category that is displayed!
This relies on using the native search capabilities in Zencart...displaying the various listing into the search page result listing.
I replaced the all_products, new, and featured links (everywhere you use them) with the advanced search links.
The advanced search can be used to build links for all and new products...easy enough.
To deal with featured products, I had to put the phrase "Featured Product" at the beginning of all of my product descriptions. Now, advanced search has a way to located by using the phase "Featured Product" as the key word. I'm sure there are many creative ways to do this...
If you are using breadcrumbs, you will have to edit your breadcrumb file.
Around line 35 of includes/init_includes/overrides/init_add_crumbs.php, replace existing code with:
PHP Code:
/*MIKE ADDED - HIDES CRUMB TRAIL WHEN HOME PAGE IS SET TO A CATEGORY*/
$myCurrentPage = $_SERVER['REQUEST_URI'];
if(strpos($myCurrentPage, 'cPath') !== false) {
/*END - CLOSING BRACKET AT THE BOTTOM*/
if (isset($cPath_array) && isset($cPath)) {
for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
$categories_query = "select categories_name
from " . TABLE_CATEGORIES_DESCRIPTION . "
where categories_id = '" . (int)$cPath_array[$i] . "'
and language_id = '" . (int)$_SESSION['languages_id'] . "'";
$categories = $db->Execute($categories_query);
//echo 'I SEE ' . (int)$cPath_array[$i] . '<br>';
if ($categories->RecordCount() > 0) {
$breadcrumb->add($categories->fields['categories_name'], zen_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
} elseif(SHOW_CATEGORIES_ALWAYS == 0) {
// if invalid, set the robots noindex/nofollow for this page
$robotsNoIndex = true;
break;
}
}
}
}/*MIKE - SEE LINE 35-38*/
Your new products link will become outdated if you do not include some sort of date function in your link.
Around line 118 of YOUR_TEMPLATE/tpl_main_page.php insert this code:
HTML Code:
/*MIKE ADDED - HIDES CRUMB TRAIL WHEN HOME PAGE IS SET TO A CATEGORY*/
$myCurrentPage = $_SERVER['REQUEST_URI'];
//echo $category_id." This is the category id";
if(strpos($myCurrentPage, 'cPath') !== false and strpos($myCurrentPage, 'products_id') == false) {
$pos = strrpos($cPath, "_");
/*echo $pos." Characters to remove from cPath to get current category";*/
if(strrpos($cPath, "_") == false) {
$myCategory = $cPath;
}else {
$myCategory = substr($cPath, $pos + 1); // returns "ef"
/*echo $myCategory." = myCategory";*/
}
?>
<div id="searchCategories">
<ul>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=+&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=&pfrom=0&pto=1000000&dfrom=&dto=&x=36&y=10">All Products</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=%22Featured+Product%22&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=&pfrom=&pto=&dfrom=&dto=&x=36&y=10">Best Deals</a>
</li>
</li><li>
<a href="index.php?main_page=advanced_search_result&keyword=+&search_in_description=1&categories_id=
<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=&pfrom=0&pto=10000000&dfrom=
<?php $date = date('m/d/Y');
$newdate = strtotime ( '-6 month' , strtotime ( $date ) ) ;
$newdate = date ( 'm/d/Y' , $newdate );
echo $newdate; ?>
&dto=&x=36&y=10">New</a>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=+&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=&pfrom=0&pto=25&dfrom=&dto=&x=36&y=10">$0 - $25</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=+&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=&pfrom=25&pto=50&dfrom=&dto=&x=36&y=10">$25 - $50</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=+&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=&pfrom=50&pto=75&dfrom=&dto=&x=36&y=10">$50 - $75</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=+&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=&pfrom=75&pto=100&dfrom=&dto=&x=36&y=10">$75 - $100</a>
</li>
</ul>
</div>
Apply these same concepts where ever you have links for all, new, and featured and you will have listings that all look the same.
Hope this helps someone.