DigiBooks:
Silly me!!!! I had another look at the code and realised that I was continually going through the function with the same master category ID!!!!
I'm nearly there now and will post the final code once it's completed
OK it's all working now - the final code changes are this:
In includes/modules/new_products.php
AFTER: while (!$new_products->EOF) {
ADD:
// DB#2 BEGIN - read in author's name
$new_manufacturer = zen_get_products_manufacturers_name($new_products->fields['products_id']);
// END DB#2
// DB#3 BEGIN - read in the book's master category ID
$new_category_master_id = zen_get_products_category_id($new_products->fields['products_id']);
// and find the top-level genre
$new_toplevel_genre_id = zen_get_toplevel_category_id($new_category_master_id);
// now collect the genre's name
$new_genre_name = zen_get_categories_name($new_toplevel_genre_id);
// END DB#3
find the line that starts: 'text' => (($new_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '<a href="' .
and replace the whole of the code with:
'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'] .
// DB#2 BEGIN - display author and remove pricing information
'</a><br />by<br />' . $new_manufacturer
// END DB#2
// DB#3 BEGIN - display the top-level genre
. '<br />(' . $new_genre_name . ')');
// END DB#3
In includes/functions/functions_lookup
ADD:
/* DB#1 BEGIN - extract the top-level genre
-
TABLES: categories
*/
function zen_get_toplevel_category_id($this_category_id) {
global $db;
global $is_toplevel_category;
global $this_parent_id;
$is_toplevel_category = $this_category_id;
$this_parent_id = 9;
do {
$the_toplevel_category_query = "select categories_id, parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . $is_toplevel_category . "'";
$the_toplevel_category = $db->Execute($the_toplevel_category_query);
$is_toplevel_category = $the_toplevel_category->fields['parent_id'];
$this_parent_id = $the_toplevel_category->fields['parent_id'];
} while ($this_parent_id >0);
$is_toplevel_category = $the_toplevel_category->fields['categories_id'];
return $is_toplevel_category;
}
/* END DB#1 */