Zen Follower
- Join Date:
- Jan 2009
- Location:
- Vegas Baby!
- Posts:
- 311
- Plugin Contributions:
- 0
Featured Products
Is there a way for me to show Featured Products on the category page without it also showing on the subcategory pages?
Views: 1,792
Zen Follower
Is there a way for me to show Featured Products on the category page without it also showing on the subcategory pages?
Zen Follower
I'm sure there is a more elegant way to handle this with php, but if you can't find another solution you can use CSS to hide the featured products from the subcategory pages. This could become very tedious if you have a large number of subcategories.
It would require creating individual stylesheets for each of the subcategories and adding #featuredProducts {display: none;}
Each stylesheet should be name based on the cpath of the subcategory. c_??_??.css.
Zen Follower
pjb923:
I'm sure there is a more elegant way to handle this with php, but if you can't find another solution you can use CSS to hide the featured products from the subcategory pages. This could become very tedious if you have a large number of subcategories.
It would require creating individual stylesheets for each of the subcategories and adding #featuredProducts {display: none;}
Each stylesheet should be name based on the cpath of the subcategory. c_??_??.css.
Thanks for the suggestion but I do have ALOT of subcategories. Wishful thinking I suppose but I thought maybe there's a particular page that generates the subcats that could just be edited...
Zen Follower
I was determined to figure this out because I am also interested in the answer.
Since all subcategories contain an underscore in the cPath, I used a simple regular expression to selectively display the featured products.
Go to line 85 of your tpl_index_categories.php file and make the following changes.
Replace:
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_FEATURED_PRODUCTS') { ?>
<?php
/**
* display the Featured Products Center Box
*/
?>
<?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?>
<?php } ?>
With this:
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_FEATURED_PRODUCTS') { ?>
<?php
/**
* display the Featured Products Center Box
*/
?>
<?php
if (preg_match("._.", $cPath)) {
echo 'disable featured products';
} else { ?>
<?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?>
<?php } ?>
<?php } ?>
You can remove the "echo 'disable featured products';" line. I put it in just to make sure everything was working properly.
Zen Follower
I tried that but the code doesn't work for me :( In fact, I don't get any featured products, just the centerbox.
Zen Follower
Try reverting back to the original code and just add the following.
<?php
if (preg_match("._.", $cPath)) {
echo 'disable featured products';
}
else {
echo 'enable featured products'; }?>
Place it just before
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_FEATURED_PRODUCTS') { ?>
Now you should see text displayed right above the featured products box and it will either say disable featured products, or enable featured products.
Zen Follower
Yes, I actually have text 3 times (?). This is my test page
Zen Follower
Sorry that's the wrong page, this is it
Zen Follower
The good news is that the expression match is working correctly because navigating to a sub-directory shows the disabled text string.
It's hard to say why it's showing up multiple times.
Also, if you entered the code as I described it should not effect the featured products display at all, and I'm not seeing anything in the featured products box on your page. If you remove the code do they display properly?
I would probably need to see your entire tpl_index_categories.php file to figure out what is going on.
Zen Follower
pjb923:
The good news is that the expression match is working correctly because navigating to a sub-directory shows the disabled text string.
It's hard to say why it's showing up multiple times.
Also, if you entered the code as I described it should not effect the featured products display at all, and I'm not seeing anything in the featured products box on your page. If you remove the code do they display properly?
I would probably need to see your entire tpl_index_categories.php file to figure out what is going on.
That's odd, I reverted back to the original page but I get an empty Featured Products centerbox...I actually don't know if it's always been like that or not, because I usually don't have it turned on.
Maybe I messed something up, this is my tpl_index_categories.php:
<?php
/**
* Page Template
*
* Loaded by main_page=index<br />
* Displays category/sub-category listing<br />
* Uses tpl_index_category_row.php to render individual items
*
* @package templateSystem
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_index_categories.php 4678 2006-10-05 21:02:50Z ajeh $
*/
?>
<div class="centerColumn" id="indexCategories">
<?php if ($show_welcome == true) { ?>
<h1 id="indexCategoriesHeading"><?php echo HEADING_TITLE; ?></h1>
<?php if (SHOW_CUSTOMER_GREETING == 1) { ?>
<h2 class="greeting"><?php echo zen_customer_greeting(); ?></h2>
<?php } ?>
<!-- deprecated - to use - uncomment
<?php if (TEXT_MAIN) { ?>
<div id="" class="content"><?php echo TEXT_MAIN; ?></div>
<?php } ?>-->
<!-- deprecated - to use - uncomment
<?php if (TEXT_INFORMATION) { ?>
<div id="" class="content"><?php echo TEXT_INFORMATION; ?></div>
<?php } ?>-->
<?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2) { ?>
<div id="indexCategoriesMainContent" class="content"><?php
/**
* require the html_define for the index/categories page
*/
include($define_page);
?></div>
<?php } ?>
<?php } else { ?>
<h1 id="indexCategoriesHeading"><?php echo $breadcrumb->last(); ?></h1>
<?php } ?>
<?php
if (PRODUCT_LIST_CATEGORIES_IMAGE_STATUS_TOP == 'true') {
// categories_image
if ($categories_image = zen_get_categories_image($current_category_id)) {
?>
<div id="categoryImgListing" class="categoryImg"><?php echo zen_image(DIR_WS_IMAGES . $categories_image, '', SUBCATEGORY_IMAGE_TOP_WIDTH, SUBCATEGORY_IMAGE_TOP_HEIGHT); ?></div>
<?php
}
} // categories_image
?>
<?php
// categories_description
if ($current_categories_description != '') {
?>
<div id="categoryDescription" class="catDescContent"><?php echo $current_categories_description; ?></div>
<?php } // categories_description ?>
<!-- BOF: Display grid of available sub-categories, if any -->
<?php
if (PRODUCT_LIST_CATEGORY_ROW_STATUS == 0) {
// do nothing
} else {
// display subcategories
/**
* require the code to display the sub-categories-grid, if any exist
*/
require($template->get_template_dir('tpl_modules_category_row.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_row.php');
}
?>
<!-- EOF: Display grid of available sub-categories -->
<?php
$show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY);
while (!$show_display_category->EOF) {
// // echo 'I found ' . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS);
?>
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_FEATURED_PRODUCTS') { ?>
<?php
/**
* display the Featured Products Center Box
*/
?>
<?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?>
<?php } ?>
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_SPECIALS_PRODUCTS') { ?>
<?php
/**
* display the Special Products Center Box
*/
?>
<?php require($template->get_template_dir('tpl_modules_specials_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_specials_default.php'); ?>
<?php } ?>
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_NEW_PRODUCTS') { ?>
<?php
/**
* display the New Products Center Box
*/
?>
<?php require($template->get_template_dir('tpl_modules_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_whats_new.php'); ?>
<?php } ?>
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_UPCOMING') { ?>
<?php include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS)); ?><?php } ?>
<?php
$show_display_category->MoveNext();
} // !EOF
?>
</div>
Zen Follower
Any luck getting this to work?
tpl_index_categories looks good to me, so there must be a problem somewhere else that is preventing the featured products from displaying properly.
Zen Follower
No, still getting an empty Featured Products box.
Tell staff why this post should be reviewed.