Let me see if I understand better now with an example.
Suppose I am in the category: Womens clothes->Summer->Skirts.
All skirts would be displayed. Skirts is the immediate category and its parent is 'Summer'. When I click on this new link on a given product in the skirts page, the parent 'Summer' is sent to a new code. The new code will look at the 'Summer' category and find all Slave Categories of 'Summer' and therefor display a consolidated page of all products that are descendants of 'Summer'?
Is that what you want to do?
Sorry. I should have given a decent example before. I think the short answer is "Yes, I think we're on the same page" but I'll put an example in my own words too to make sure...
Let's say that this is one product displayed in the listing for the category "Ibiza Collection(1)":
I have a database table in which "Ibiza Collection(1)" is the Master and the following categories are Slave (each Master>Slave relationship is a separate database entry):
In the listing item for Product X I would like to have a button to associated products. This link could either send its parent category ID or its own ID to the new code. This code should then somehow get all of the products from the slave categories and display them. I've got the idea of displaying them in random order because that's one of the options of the ORP contrib.
The Optional Related Products contribution displays related products in the product_info page below the product information by calling a list from optional_related_products.php. This doesn't work for me even if I could adapt it to show the contents of various categories as I've done away with the product_info page . I've got everything in the product listing (attributes, product description, tell a friend, enlarge image, etc...). However, I don't know if the code it uses to display the related products might be a good starting point if it then gets put into into a new .php file to display a list there instead of in the index.
<?php
/*
$Id: optional_related_products.php, ver 1.0 02/05/2007 Exp $
variation to support contribution: Graphical Borders 2.1
Copyright © 2007 Anita Cross (http://www.callofthewildphoto.com/)
Part of Contribution: Optional Related Products Ver 4.0
Based on code from Optional Relate Products, ver 2.0 05/01/2005
Copyright © 2004-2005 Daniel Bahna (daniel.bahna@gmail.com)
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com Released under the GNU General Public License
*/
$orderBy = 'ORDER BY ';
$orderBy .= (RELATED_PRODUCTS_RANDOMIZE)?'rand()':'pop_order_id, pop_id';
$orderBy .= (RELATED_PRODUCTS_MAX_DISP)?' limit ' . RELATED_PRODUCTS_MAX_DISP:'';
$attributes = "
SELECT
pop_products_id_slave,
products_name,
products_model,
products_price,
products_quantity,
products_tax_class_id,
products_image
FROM " .
TABLE_PRODUCTS_RELATED_PRODUCTS . ", " .
TABLE_PRODUCTS_DESCRIPTION . " pa, ".
TABLE_PRODUCTS . " pb
WHERE pop_products_id_slave = pa.products_id
AND pa.products_id = pb.products_id
AND language_id = '" . (int)$languages_id . "'
AND pop_products_id_master = '".$HTTP_GET_VARS['products_id']."'
AND products_status='1' " . $orderBy;
$attribute_query = tep_db_query($attributes);
if (mysql_num_rows($attribute_query)>0) {
$count = 0;
?>
<tr>
<?php echo mws_header(TEXT_RELATED_PRODUCTS); ?>
<td align="center" class="productListing-data">
<table border="0" cellspacing="0" cellpadding="2" width="100%" align="center">
<tr>
<?php
while ($attributes_values = tep_db_fetch_array($attribute_query)) {
$products_name_slave = ($attributes_values['products_name']);
$products_model_slave = ($attributes_values['products_model']);
$products_qty_slave = ($attributes_values['products_quantity']);
$products_id_slave = ($attributes_values['pop_products_id_slave']);
if ($new_price = tep_get_products_special_price($products_id_slave)) {
$products_price_slave = $currencies->display_price($new_price, tep_get_tax_rate($attributes_values['products_tax_class_id']));
} else {
$products_price_slave = $currencies->display_price($attributes_values['products_price'], tep_get_tax_rate($attributes_values['products_tax_class_id']));
}
echo '<td class="productListing-data" align="center">' . "\n";
// show thumb image if Enabled
if (RELATED_PRODUCTS_SHOW_THUMBS == 'True') {
echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">' . "\n"
. tep_image(DIR_WS_IMAGES . $attributes_values['products_image'], $attributes_values['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"').'</a><br>' . "\n";
}
$caption = '';
if (RELATED_PRODUCTS_SHOW_NAME == 'True') {
$caption .= '<p>' . $products_name_slave . '</p>' . "\n";
if (RELATED_PRODUCTS_SHOW_MODEL == 'True') {
$caption .= '<p>' . $products_model_slave . '</p>' . "\n";
}
} elseif (RELATED_PRODUCTS_SHOW_MODEL == 'True') {
$caption .= '<p>' . $products_model_slave . '</p>' . "\n";
}
if (RELATED_PRODUCTS_SHOW_PRICE == 'True') {
$caption .= '<p>' . sprintf(RELATED_PRODUCTS_PRICE_TEXT, $products_price_slave) . '</p>' . "\n";
}
if (RELATED_PRODUCTS_SHOW_QUANTITY == 'True') {
$caption .= '<p>' . sprintf(RELATED_PRODUCTS_QUANTITY_TEXT, $products_qty_slave) . '</p>' . "\n";
}
echo '<a href="'
. tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id_slave) . '">'
. $caption . '</a>' . "\n";
if (RELATED_PRODUCTS_SHOW_BUY_NOW== 'True') {
echo '<a href="'
. tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))
. 'action=rp_buy_now&rp_products_id=' . $products_id_slave) . '">'
. tep_image_button('button_rp_buy_now.gif', IMAGE_BUTTON_RP_BUY_NOW) . '</a>';
}
echo '</td>' . "\n";
$count++;
if ((RELATED_PRODUCTS_USE_ROWS == 'True') && ($count%RELATED_PRODUCTS_PER_ROW == 0)) {
echo '</tr><tr>' . "\n";
}
}
?>
</tr></table>
</td>
<?php echo mws_footer(''); ?>
</tr>
<?php
}
?>