Zen Cart Logo

Featured Products

Locked

Views: 1,792

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
21 Nov 2009, 8:33 PM
#1
charinlasvegas avatar

charinlasvegas

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?

23 Nov 2009, 6:09 PM
#2
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Re: Featured Products

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.

24 Nov 2009, 1:47 AM
#3
charinlasvegas avatar

charinlasvegas

Zen Follower

Join Date:
Jan 2009
Location:
Vegas Baby!
Posts:
311
Plugin Contributions:
0

Re: Featured Products

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...

24 Nov 2009, 3:19 PM
#4
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Re: Featured Products

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.

24 Nov 2009, 3:56 PM
#5
charinlasvegas avatar

charinlasvegas

Zen Follower

Join Date:
Jan 2009
Location:
Vegas Baby!
Posts:
311
Plugin Contributions:
0

Re: Featured Products

I tried that but the code doesn't work for me :( In fact, I don't get any featured products, just the centerbox.

24 Nov 2009, 4:29 PM
#6
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Re: Featured Products

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.

24 Nov 2009, 4:39 PM
#7
charinlasvegas avatar

charinlasvegas

Zen Follower

Join Date:
Jan 2009
Location:
Vegas Baby!
Posts:
311
Plugin Contributions:
0

Re: Featured Products

Yes, I actually have text 3 times (?). This is my test page

24 Nov 2009, 4:49 PM
#8
charinlasvegas avatar

charinlasvegas

Zen Follower

Join Date:
Jan 2009
Location:
Vegas Baby!
Posts:
311
Plugin Contributions:
0

Re: Featured Products

Sorry that's the wrong page, this is it

24 Nov 2009, 5:46 PM
#9
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Re: Featured Products

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.

24 Nov 2009, 6:07 PM
#10
charinlasvegas avatar

charinlasvegas

Zen Follower

Join Date:
Jan 2009
Location:
Vegas Baby!
Posts:
311
Plugin Contributions:
0

Re: Featured Products

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>
30 Nov 2009, 2:17 PM
#11
pjb923 avatar

pjb923

Zen Follower

Join Date:
Jan 2005
Location:
NY
Posts:
135
Plugin Contributions:
0

Re: Featured Products

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.

1 Dec 2009, 2:48 PM
#12
charinlasvegas avatar

charinlasvegas

Zen Follower

Join Date:
Jan 2009
Location:
Vegas Baby!
Posts:
311
Plugin Contributions:
0

Re: Featured Products

No, still getting an empty Featured Products box.