Forums / Templates, Stylesheets, Page Layout / new monthly AND new weekly?

new monthly AND new weekly?

Locked

Views: 1,483

Results 1 to 12 of 12
This thread is locked. New replies are disabled.
6 Nov 2010, 6:16 PM
#1
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

new monthly AND new weekly?

So, I'd like to try and figure out how to display, on the front/index page, both a box of products that are new this month AND a box of products that are new this week. I want to display both of them to be in the center column. I'll display the monthly box in alphabetical order & the weekly box in order by date, so they won't look "the same" to customers.

I figure the easiest thing would be to edit includes/modules/new_products.php (but not includes/templates/template_default/templates/tpl_modules_products_new_listing.php, as that doesn't govern the index page, correct?). I'm thinking I will duplicate part of the code that is already there in order to build a 2nd box that displays in the center column.

My knowledge of php coding is a bit spotty, so I'm hoping to talk myself through it a bit here.

Looks like in new_products.php I will have to hard code the MAX_DISPLAY_NEW_PRODUCTS variable in the clone box, as well as the $display_limit variable.

Hmmm, I'm not sure exactly what should & shouldn't be duplicated, I guess. Anyone who is facile with php and would know how to point me a little bit further?

6 Nov 2010, 7:17 PM
#2
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

Re: new monthly AND new weekly?

Here's my 1st, somewhat crude attempt. It's doesn't throw an SQL error, but the result isn't what I'd hoped for either. I don't see both the monthly and weekly sections on the front page, just the weekly (latter) one.

<?php 
/** 
 * new_products.php module 
 * 
 * @package modules 
 * @copyright Copyright 2003-2007 Zen Cart Development Team 
 * @copyright Portions Copyright 2003 osCommerce 
 * @license [url]http://www.zen-cart.com/license/2_0.txt[/url] GNU Public License V2.0 
 * @version $Id: new_products.php 6424 2007-05-31 05:59:21Z ajeh $ 
 */ 
if (!defined('IS_ADMIN_FLAG')) { 
  die('Illegal Access'); 
} 

// initialize vars 
$categories_products_id_list = ''; 
$list_of_products = ''; 
$new_products_query = ''; 

$display_limit = zen_get_new_date_range(); 

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) { 
  $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 
                                p.products_date_added, p.products_price, p.products_type, p.master_categories_id 
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                           where p.products_id = pd.products_id 
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' 
                           and   p.products_status = 1 " . $display_limit; 
                            $new_products_query .= " ORDER BY products_date_added DESC 
                        LIMIT " . MAX_DISPLAY_NEW_PRODUCTS; 
} else { 
  // get all products and cPaths in this subcat tree 
  $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit); 

  if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) { 
    // build products-list string to insert into SQL query 
    foreach($productsInCategory as $key => $value) { 
      $list_of_products .= $key . ', '; 
    } 
    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma 

    $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 
                                  p.products_date_added, p.products_price, p.products_type, p.master_categories_id 
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                           where p.products_id = pd.products_id 
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' 
                           and p.products_id in (" . $list_of_products . ")"; 
                            
                           $new_products_query .= " ORDER BY products_date_added DESC 
                        LIMIT " . MAX_DISPLAY_NEW_PRODUCTS; 
  } 
} 


if ($new_products_query != '') $new_products = $db->Execute($new_products_query); 

$row = 0; 
$col = 0; 
$list_box_contents = array(); 
$title = ''; 

$num_products_count = ($new_products_query == '') ? 0 : $new_products->RecordCount(); 

// show only when 1 or more 
if ($num_products_count > 0) { 
  if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == 0 ) { 
    $col_width = floor(100/$num_products_count); 
  } else { 
    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS); 
  } 

  while (!$new_products->EOF) { 
    $products_price = zen_get_products_display_price($new_products->fields['products_id']); 
    if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']); 

    $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"', 
    'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br />' . $products_price); 

    $col ++; 
    if ($col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS - 1)) { 
      $col = 0; 
      $row ++; 
    } 
    $new_products->MoveNext(); 
  } 

  if ($new_products->RecordCount() > 0) { 
    if (isset($new_products_category_id) && $new_products_category_id != 0) { 
      $category_title = zen_get_categories_name((int)$new_products_category_id); 
      $title = '<h2 class="centerBoxHeading">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '</h2>'; 
    } else { 
      $title = '<h2 class="centerBoxHeading">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . '</h2>'; 
    } 
    $zc_show_new_products = true; 
  } 
} 


?><?php

$display_limit = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 7'; 

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) { 
  $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 
                                p.products_date_added, p.products_price, p.products_type, p.master_categories_id 
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                           where p.products_id = pd.products_id 
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' 
                           and   p.products_status = 1 " . $display_limit; 
                            $new_products_query .= " ORDER BY products_date_added DESC 
                        LIMIT " . MAX_DISPLAY_NEW_PRODUCTS; 
} else { 
  // get all products and cPaths in this subcat tree 
  $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit); 

  if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) { 
    // build products-list string to insert into SQL query 
    foreach($productsInCategory as $key => $value) { 
      $list_of_products .= $key . ', '; 
    } 
    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma 

    $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 
                                  p.products_date_added, p.products_price, p.products_type, p.master_categories_id 
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                           where p.products_id = pd.products_id 
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' 
                           and p.products_id in (" . $list_of_products . ")"; 
                            
                           $new_products_query .= " ORDER BY products_date_added DESC 
                        LIMIT " . MAX_DISPLAY_NEW_PRODUCTS; 
  } 
} 


if ($new_products_query != '') $new_products = $db->Execute($new_products_query); 

$row = 0; 
$col = 0; 
$list_box_contents = array(); 
$title = ''; 

$num_products_count = ($new_products_query == '') ? 0 : $new_products->RecordCount(); 

// show only when 1 or more 
if ($num_products_count > 0) { 
  if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == 0 ) { 
    $col_width = floor(100/$num_products_count); 
  } else { 
    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS); 
  } 

  while (!$new_products->EOF) { 
    $products_price = zen_get_products_display_price($new_products->fields['products_id']); 
    if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']); 

    $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"', 
    'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br />' . $products_price); 

    $col ++; 
    if ($col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS - 1)) { 
      $col = 0; 
      $row ++; 
    } 
    $new_products->MoveNext(); 
  } 

  if ($new_products->RecordCount() > 0) { 
    if (isset($new_products_category_id) && $new_products_category_id != 0) { 
      $category_title = zen_get_categories_name((int)$new_products_category_id); 
      $title = '<h2 class="centerBoxHeading">' . sprintf("New This Week", strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '</h2>'; 
    } else { 
      $title = '<h2 class="centerBoxHeading">' . sprintf("New This Week", strftime('%B')) . '</h2>'; 
    } 
    $zc_show_new_products = true; 
  } 
} 


?>
6 Nov 2010, 8:53 PM
#3
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

Re: new monthly AND new weekly?

I wonder if this snippet

if ($new_products->RecordCount() > 0) {
if (isset($new_products_category_id) && $new_products_category_id != 0)

is my problem? I have a vague idea that resetting variable numbers is what's causing the code to write over the initial query/display so that only the 2nd query/display is actually rendered. Hmmmmm.

8 Nov 2010, 11:41 PM
#4
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

Re: new monthly AND new weekly?

Still haven't figured this out. I've tried changing some of the variables in the 2nd half of the new_products.php file (for example, $new_products_category_id is now $new_products_category_ida, but just during the 2nd iteration. Hasn't worked, unfortunately, and I'm out of ideas. Anybody?

26 Nov 2010, 12:06 AM
#5
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

Re: new monthly AND new weekly?

Still trying to figure this out. If nobody knows enough php, any place you could recommend to get a better hold on it?

26 Nov 2010, 12:16 AM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: new monthly AND new weekly?

You have made a clone of the new_products.php module, correct?

Did you clone the tpl_modules_whats_new.php to call the cloned file that you made of new_products.php file?

Did you then add the call to the tpl_modules_whats_new.php in all of the files where the original tpl_modules_whats_new.php is called?

What does your completed clone of the new_products.php look like?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Nov 2010, 12:58 AM
#7
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

Re: new monthly AND new weekly?

Thanks very much for your time & help, Ajeh.

Nope, actually I did not clone the new_products.php. Since I only want the monthly new and weekly new lists to show up on the main index page & don't need it anyplace else, I was just editing the code in new_products.php. I wanted to get it to display 2 boxes instead of one. Does that not make sense, for some reason I've missed?

The file I have currently looks like this:

<?php 
/** 
 * new_products.php module 
 * 
 * @package modules 
 * @copyright Copyright 2003-2007 Zen Cart Development Team 
 * @copyright Portions Copyright 2003 osCommerce 
 * @license [url]http://www.zen-cart.com/license/2_0.txt[/url] GNU Public License V2.0 
 * @version $Id: new_products.php 6424 2007-05-31 05:59:21Z ajeh $ 
 */ 
if (!defined('IS_ADMIN_FLAG')) { 
  die('Illegal Access'); 
} 

// initialize vars 
$categories_products_id_list = ''; 
$list_of_products = ''; 
$new_products_query = ''; 

$display_limit = zen_get_new_date_range(); 

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) { 
  $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 
                                p.products_date_added, p.products_price, p.products_type, p.master_categories_id 
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                           where p.products_id = pd.products_id 
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' 
                           and   p.products_status = 1 " . $display_limit; 
                            $new_products_query .= " ORDER BY products_date_added DESC 
                        LIMIT " . MAX_DISPLAY_NEW_PRODUCTS; 
} else { 
  // get all products and cPaths in this subcat tree 
  $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit); 

  if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) { 
    // build products-list string to insert into SQL query 
    foreach($productsInCategory as $key => $value) { 
      $list_of_products .= $key . ', '; 
    } 
    $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma 

    $new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 
                                  p.products_date_added, p.products_price, p.products_type, p.master_categories_id 
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                           where p.products_id = pd.products_id 
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' 
                           and p.products_id in (" . $list_of_products . ")"; 
                            
                           $new_products_query .= " ORDER BY products_date_added DESC 
                        LIMIT " . MAX_DISPLAY_NEW_PRODUCTS; 
  } 
} 


if ($new_products_query != '') $new_products = $db->Execute($new_products_query); 

$row = 0; 
$col = 0; 
$list_box_contents = array(); 
$title = ''; 

$num_products_count = ($new_products_query == '') ? 0 : $new_products->RecordCount(); 

// show only when 1 or more 
if ($num_products_count > 0) { 
  if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == 0 ) { 
    $col_width = floor(100/$num_products_count); 
  } else { 
    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS); 
  } 

  while (!$new_products->EOF) { 
    $products_price = zen_get_products_display_price($new_products->fields['products_id']); 
    if (!isset($productsInCategory[$new_products->fields['products_id']])) $productsInCategory[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']); 

    $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"', 
    'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br />' . $products_price); 

    $col ++; 
    if ($col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS - 1)) { 
      $col = 0; 
      $row ++; 
    } 
    $new_products->MoveNext(); 
  } 

  if ($new_products->RecordCount() > 0) { 
    if (isset($new_products_category_id) && $new_products_category_id != 0) { 
      $category_title = zen_get_categories_name((int)$new_products_category_id); 
      $title = '<h2 class="centerBoxHeading">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '</h2>'; 
    } else { 
      $title = '<h2 class="centerBoxHeading">' . sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')) . '</h2>'; 
    } 
    $zc_show_new_products = true; 
  } 
} 






?><?php

$display_limita = ' and TO_DAYS(NOW()) - TO_DAYS(p.products_date_added) <= 7'; 

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_ida) || $new_products_category_ida == '0') ) { 
  $new_products_querya = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 
                                p.products_date_added, p.products_price, p.products_type, p.master_categories_id 
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                           where p.products_id = pd.products_id 
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' 
                           and   p.products_status = 1 " . $display_limita; 
                            $new_products_querya .= " ORDER BY products_date_added DESC 
                        LIMIT " . MAX_DISPLAY_NEW_PRODUCTS; 
} else { 
  // get all products and cPaths in this subcat tree 
  $productsInCategorya = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limita); 

  if (is_array($productsInCategorya) && sizeof($productsInCategorya) > 0) { 
    // build products-list string to insert into SQL query 
    foreach($productsInCategorya as $key => $value) { 
      $list_of_productsa .= $key . ', '; 
    } 
    $list_of_productsa = substr($list_of_productsa, 0, -2); // remove trailing comma 

    $new_products_querya = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name, 
                                  p.products_date_added, p.products_price, p.products_type, p.master_categories_id 
                           from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd 
                           where p.products_id = pd.products_id 
                           and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' 
                           and p.products_id in (" . $list_of_products . ")"; 
                            
                           $new_products_querya .= " ORDER BY products_date_added DESC 
                        LIMIT " . MAX_DISPLAY_NEW_PRODUCTS; 
  } 
} 


if ($new_products_querya != '') $new_products = $db->Execute($new_products_querya); 

$row = 0; 
$col = 0; 
$list_box_contents = array(); 
$title = ''; 

$num_products_count = ($new_products_querya == '') ? 0 : $new_products->RecordCount(); 

// show only when 1 or more 
if ($num_products_count > 0) { 
  if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS == 0 ) { 
    $col_width = floor(100/$num_products_count); 
  } else { 
    $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS); 
  } 

  while (!$new_products->EOF) { 
    $products_price = zen_get_products_display_price($new_products->fields['products_id']); 
    if (!isset($productsInCategorya[$new_products->fields['products_id']])) $productsInCategorya[$new_products->fields['products_id']] = zen_get_generated_category_path_rev($new_products->fields['master_categories_id']); 

    $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsNew centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"', 
    'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategorya[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . $new_products->fields['products_image'], $new_products->fields['products_name'], IMAGE_PRODUCT_NEW_WIDTH, IMAGE_PRODUCT_NEW_HEIGHT) . '</a><br />') . '<a href="' . zen_href_link(zen_get_info_page($new_products->fields['products_id']), 'cPath=' . $productsInCategorya[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']) . '">' . $new_products->fields['products_name'] . '</a><br />' . $products_price); 

    $col ++; 
    if ($col > (SHOW_PRODUCT_INFO_COLUMNS_NEW_PRODUCTS - 1)) { 
      $col = 0; 
      $row ++; 
    } 
    $new_products->MoveNext(); 
  } 

  if ($new_products->RecordCount() > 0) { 
    if (isset($new_products_category_ida) && $new_products_category_ida!= 0) { 
      $category_title = zen_get_categories_name((int)$new_products_category_ida); 
      $title = '<h2 class="centerBoxHeading">' . sprintf("New This Week", strftime('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '</h2>'; 
    } else { 
      $title = '<h2 class="centerBoxHeading">' . sprintf("New This Week", strftime('%B')) . '</h2>'; 
    } 
    $zc_show_new_products = true; 
  } 
} 


?>
26 Nov 2010, 1:10 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: new monthly AND new weekly?

All of the code in the new_product.php module is needed to build the default New Product module and that is called from the tpl_modules_whats_new.php which is called from the various files ...

It would be easier to clone the new_product.php module and alter the:
$display_limit = zen_get_new_date_range();

to call just the last 7 days:
$display_limit = zen_get_new_date_range(7);

then make a clone of the tpl_modules_whats_new.php to call that so you can include it where you need it to show both the New Products of the Week and New Products of whatever date period you use ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Nov 2010, 1:19 AM
#9
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

Re: new monthly AND new weekly?

Okay- so it looks like the file that calls tpl_modules_whats_new.php is this one:

tpl_index_default.php

Is that in fact the file that "draws the box" on the index page?

26 Nov 2010, 1:42 AM
#10
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

Re: new monthly AND new weekly?

So,

  1. I've made a copy of new_products.php with a new name
  2. In that new file, I changed the date range to > $display_limit = zen_get_new_date_range(7);
  3. I've also made a copy of tpl_modules_whats_new.php with a new name.
  4. In this new file, I've changed > FILENAME_NEW_PRODUCTS to reflect the new name of new_products.php
  5. I've added a line to includes/filenames.php, by cloning the line

define('FILENAME_NEW_PRODUCTS', 'new_products.php'); and adding the new name to the cloned line

  1. I'm now editing tpl_index_default.php. I cloned these lines:
<?php require($template->get_template_dir('tpl_modules_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_whats_new.php'); ?> <?php } ?>

and in the cloned lines I used the new file names.

I should be close now, but I'm still getting a blank center box on my index page.

26 Nov 2010, 1:50 AM
#11
weirdorecords avatar

weirdorecords

New Zenner

Join Date:
May 2010
Posts:
72
Plugin Contributions:
0

Re: new monthly AND new weekly?

Ah-ha! Got it. I just had an unclosed bracket because I'd copied too much in #6 above. Only

<?php require($template->get_template_dir('tpl_modules_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_whats_new.php'); ?>

needs to be changed.

Thanks so much for your helpful re-direction Ajeh. I've been :frusty: for weeks & now it's solved in just a few minutes.

26 Nov 2010, 2:18 AM
#12
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: new monthly AND new weekly?

You are most welcome ... glad that this was of help to you ... :smile:

NOTE: tpl_modules_whats_new.php is called by multiple files ... be sure you have addressed all of the ones that you want to call both your 7 day and the original ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!