Zen Follower
- Join Date:
- Sep 2012
- Location:
- West Jefferson, NC
- Posts:
- 391
- Plugin Contributions:
- 0
Using one single listing template
Thanks for the warning and info.
Views: 90,805
Zen Follower
Thanks for the warning and info.
New Zenner
Hi, I know this thread is quite old but I thought I would try my luck anyway and hope that somebody out there would be generous enough to offer a helping hand with a little problem I am having. :dontgetit
I have installed the 'Single Listing Module' and pretty much have everything working as intended with the exception of one thing. The 'Sort by' dropdown menu that appears on my 'Specials' page does not seem to respond when changed. I am stuck with displaying the most recent special offers only. Whilst I would like to keep the Specials appearing from 'New to Old' as default, it would be nice to give customers the choice of changing the option to improve utility.
I have seen the posts earlier in this thread and tried some of the suggestions based on the files:
/includes/modules/pages/specials/header_php.php
/includes/modules/pages/specials/main_template_vars.php
But they do not seem to do anything to resolve the issue, if anything it made matters worse and I had to revert it back.
I am not big on PHP so I am really hoping there will be a kind soul out there somewhere that would kindly help me get this working again. :frusty:
Here is the code from my header_php.php:
*
And here is my code from main_template_vars.php:
*<?php
/**Single Listing Template mod v1.8
if (MAX_DISPLAY_SPECIAL_PRODUCTS > 0 ) {
$specials_query_raw = "SELECT p.products_id, p.products_image, pd.products_name,
p.master_categories_id
FROM (" . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_SPECIALS . " s on p.products_id = s.products_id
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
WHERE p.products_id = s.products_id and p.products_id = pd.products_id and p.products_status = '1'
AND s.status = 1
AND pd.language_id = :languagesID
ORDER BY s.specials_date_added DESC";
$specials_query_raw = $db->bindVars($specials_query_raw, ':languagesID', $_SESSION['languages_id'], 'integer');
$specials_split = new splitPageResults($specials_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);
$specials = $db->Execute($specials_split->sql_query);
$row = 0;
$col = 0;
$list_box_contents = array();
$title = '';
$num_products_count = $specials->RecordCount();
if ($num_products_count) {
if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS==0 ) {
$col_width = floor(100/$num_products_count);
} else {
$col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS);
}
$list_box_contents = array();
while (!$specials->EOF) {
$products_price = zen_get_products_display_price($specials->fields['products_id']);
$specials->fields['products_name'] = zen_get_products_name($specials->fields['products_id']);
$list_box_contents[$row][$col] = array('params' => 'class="specialsListBoxContents"' . ' ' . 'style="width:' . $col_width . '%;"',
'text' => '<a href="' . zen_href_link(zen_get_info_page($specials->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($specials->fields['master_categories_id']) . '&products_id=' . $specials->fields['products_id']) . '">' . (($specials->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : zen_image(DIR_WS_IMAGES . $specials->fields['products_image'], $specials->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>') . '<br /><a href="' . zen_href_link(zen_get_info_page($specials->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($specials->fields['master_categories_id']) . '&products_id=' . $specials->fields['products_id']) . '">' . $specials->fields['products_name'] . '</a><br />' . $products_price);
$col ++;
if ($col > (SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS - 1)) {
$col = 0;
$row ++;
}
$specials->MoveNext();
}
require($template->get_template_dir('tpl_specials_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_specials_default.php');
}
}
?>*
I really hope there is something simply in there that somebody can point out to me, because I just don't have the know how to see it. :(
My site uses Zen Cart version 1.3.9f if that would make any difference and you can find the link to my website here:
http://www.anglerscorner.co.uk
Thank s in advance :)
Totally Zenned
I don't think you are being ignored, it's just unlikely anyone is really in a position to help, as it needs some investigation and given the old mod and your shop being old code I would re-iterate my post #320 (remove the mod, upgrade your shop and re-do the templates) as this code is unsupported.
Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...
Zen Follower
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:
/*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:
/*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.
Zen Follower
I updated the code to make searches even more intelligent...
Find this in /YOUR TEMPLATE/templates/common/tpl_main_page.php:
<div id="bannerThree" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
}
}
?>
...and paste the code below into your document.
<?php
//MIKE ADDED CATEGORY SEARCH CRITERIEA
$myCurrentPage = $_SERVER['REQUEST_URI'];
//echo $myCurrentPage . ' - myCurrentPage<br>';
//if(strpos($myCurrentPage, '_') == !false) {
//KEY WORD
if (strripos($myCurrentPage, 'Free')) {
$myKeyword = '%22Free+Shipping%22';
} elseif (strripos ($myCurrentPage, 'Featured')) {
$myKeyword = '%22Featured+Product%22';
} else {
$myKeyword = '+';
}
//DATE STUFF
$date = date('m/d/Y');
$newdate = strtotime ( '-' . SHOW_NEW_PRODUCTS_LIMIT . ' day' , strtotime ( $date ) ) ;
$newdate = date ( 'm/d/Y' , $newdate );
if (strpos($myCurrentPage, "$date") !== false) {
$date_to = "$date";
$date_from = "$newdate";
} else {
$date_to = '';
$date_from = '';
}
//CATEGORY
$pos = strrpos($cPath, "_");
if(strrpos($cPath, "_") == false) {
$myCategory = $cPath;
}else {
$myCategory = substr($cPath, $pos + 1); // returns "ef"
}
if(!is_numeric($myCategory)) {
$myCategory = substr($myCurrentPage, strpos($myCurrentPage, 'categories_id=') + strlen('categories_id='));
if (strstr ($myCategory,'&inc_subcat',TRUE) != FALSE) {
$myCategory = strstr ($myCategory,'&inc_subcat',TRUE);
} else {
$myCategory = '';
}
}
//PRICE FROM & TO
$priced_from = substr($myCurrentPage, strpos($myCurrentPage, 'pfrom=') + strlen('pfrom='));
if (strstr ($priced_from,'&pto',TRUE) != FALSE) {
$priced_from = strstr ($priced_from,'&pto',TRUE);
} else {
$priced_from = '';
}
$priced_to = substr($myCurrentPage, strpos($myCurrentPage, 'pto=') + strlen('pto='));
if (strstr ($priced_to,'&dfrom',TRUE) != FALSE) {
$priced_to = strstr ($priced_to,'&dfrom',TRUE);
} else {
$priced_to = '';
}
//RESET
if(is_numeric($manufacturers_id)) {
$reset = "<a href='index.php?main_page=index&manufacturers_id={$manufacturers_id}'>--Reset--</a>";
} else {
$reset = "<a href='index.php?main_page=index&cPath={$myCategory}'>--Reset--</a>";
}
?>
<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=<?php echo $manufacturers_id; ?>&pfrom=0&pto=1000000&dfrom=<?php echo $date_from; ?>&dto=<?php echo $date_to; ?>">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=<?php echo $manufacturers_id; ?>&pfrom=<?php echo $priced_from; ?>&pto=<?php echo $priced_to; ?>&dfrom=<?php echo $date_from; ?>&dto=<?php echo $date_to; ?>">Best Deals</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=%22Free+Shipping%22&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=<?php echo $manufacturers_id; ?>&pfrom=<?php echo $priced_from; ?>&pto=<?php echo $priced_to; ?>&dfrom=<?php echo $date_from; ?>&dto=<?php echo $date_to; ?>">Free Shipping</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=<?php echo $myKeyword; ?>&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=<?php echo $manufacturers_id; ?>&pfrom=<?php echo $priced_from; ?>&pto=<?php echo $priced_to; ?>&dfrom=<?php echo $newdate; ?>&dto=<?php echo $date; ?>">New</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=<?php echo $myKeyword; ?>&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=<?php echo $manufacturers_id; ?>&pfrom=0&pto=25&dfrom=<?php echo $date_from; ?>&dto=<?php echo $date_to; ?>">$0 - $25</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=<?php echo $myKeyword; ?>&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=<?php echo $manufacturers_id; ?>&pfrom=25&pto=50&dfrom=<?php echo $date_from; ?>&dto=<?php echo $date_to; ?>">$25 - $50</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=<?php echo $myKeyword; ?>&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=<?php echo $manufacturers_id; ?>&pfrom=50&pto=75&dfrom=<?php echo $date_from; ?>&dto=<?php echo $date_to; ?>">$50 - $75</a>
</li>
<li>
<a href="index.php?main_page=advanced_search_result&keyword=<?php echo $myKeyword; ?>&search_in_description=1&categories_id=<?php echo $myCategory; ?>&inc_subcat=1&manufacturers_id=<?php echo $manufacturers_id; ?>&pfrom=75&pto=100&dfrom=<?php echo $date_from; ?>&dto=<?php echo $date_to; ?>">$75 - $100</a>
</li>
<li>
<?php echo $reset; ?>
</li>
</ul>
</div>
<?php //} /*END MIKE*/?>
Turn off all links to the native zencart links for All, Featured, and New.
Now all of your listings will look like your product page listing!
Administrator
You can also use the (currently supported) SNAF (Specials,New,All,Featured) plugin which also uses a single formatting template for those listings as well as the products' listings.
Zen Follower
lat9:
You can also use the (currently supported) SNAF (Specials,New,All,Featured) plugin which also uses a single formatting template for those listings as well as the products' listings.
Thanks for the tip! I'll check it out.
Tell staff why this post should be reviewed.