lilqhgal Posted September 22, 2005 Posted September 22, 2005 Is there anyway to restrict the category that the "random" images are pulled from? Is there a contrib out there? Or is there someway to edit the rnd_products.php file to accomplish this? Thanks!!
dahui Posted September 22, 2005 Posted September 22, 2005 Is there anyway to restrict the category that the "random" images are pulled from? Is there a contrib out there? Or is there someway to edit the rnd_products.php file to accomplish this? Thanks!! <{POST_SNAPBACK}> as usual it might be me ;) but I do not understand what you would like o do and btw which rnd_products.php? dahui
lilqhgal Posted September 23, 2005 Author Posted September 23, 2005 Okay, sorry I'll try to be a little more specific. I'm setting up a storefront for a client, and she has indicated that on the main page (index), she wants the random images that are being displayed at the bottom center of the page to come from only one category. Is there an admin setting or some particular hack I can do to restrict the displaying of those random images to come from only one category, instead of ALL of them? The rnd_products.php file is in the modules directory, and it is called from the index.php file on (or around) line 318 -- <td><?php include(DIR_WS_MODULES . FILENAME_RND_PRODUCTS); ?></td> Thanks
dahui Posted September 23, 2005 Posted September 23, 2005 ok got ya! LOL ;) rnd_products.php is not osc vanilla must come from a contrib ??? or do I miss s.th. from the very beginning :) but yo can create yr own kind of BIGBOX to extend to the sites width and include that into index.php where ever you want. basically that is what my top-10-site does http://elflein-kosmetik.de/most_sold_prod.php and the content is just a question of the select statement and html arrangement dahui
lilqhgal Posted September 23, 2005 Author Posted September 23, 2005 Okay yup it's a contrib! Sorry! *duh* Anyhow, it seems pretty straight forward, grabs random images from the catalog and displays on front page. However, I've been trying to restrict it to one specific category for the past day and just can't get the code right. Can anybody help? Here's the code I'm working with: <?php //SET THE QUERYS $sql_query[0] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_ordered asc limit " . MAX_DISPLAY_NEW_PRODUCTS); $sql_query[1] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_last_modified desc limit " . MAX_DISPLAY_NEW_PRODUCTS); $sql_query[2] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_quantity desc limit " . MAX_DISPLAY_NEW_PRODUCTS); $sql_query[3] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_available desc limit " . MAX_DISPLAY_NEW_PRODUCTS); $sql_query[4] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added asc limit " . MAX_DISPLAY_NEW_PRODUCTS); // get a random number $randomize = rand(0, 4); $rndChooser = $sql_query[$randomize]; ?> <?php $info_box_contents = array(); if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { $new_products_query = $rndChooser; } else { $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } $row = 0; $col = 0; $info_box_contents = array(); while ($new_products = tep_db_fetch_array($new_products_query)) { $new_products['products_name'] = tep_get_products_name($new_products['products_id']); $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br> '); $col ++; if ($col > 2) { $col = 0; $row ++; } } new contentBox($info_box_contents); ?> I tried changing if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) to if ( (!isset($new_products_category_id)) || ($new_products_category_id == '35') ) (since the category I'm trying to restrict it to is #35), but that hasn't worked so far.
lilqhgal Posted September 23, 2005 Author Posted September 23, 2005 GEEZ!!! Nevermind! I spent the past day trying to figure this out, posted this message, and then the NEXT try I gave, it worked. LOL! Here's my modified code: <?php //SET THE QUERYS $sql_query[0] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_ordered asc limit " . MAX_DISPLAY_NEW_PRODUCTS); $sql_query[1] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_last_modified desc limit " . MAX_DISPLAY_NEW_PRODUCTS); $sql_query[2] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_quantity desc limit " . MAX_DISPLAY_NEW_PRODUCTS); $sql_query[3] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_available desc limit " . MAX_DISPLAY_NEW_PRODUCTS); $sql_query[4] = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by p.products_date_added asc limit " . MAX_DISPLAY_NEW_PRODUCTS); // get a random number $randomize = rand(0, 4); $rndChooser = $sql_query[$randomize]; ?> <?php $info_box_contents = array(); if ( (!isset($new_products_category_id)) || ($new_products_category_id == '35') ) { $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS); } $row = 0; $col = 0; $info_box_contents = array(); while ($new_products = tep_db_fetch_array($new_products_query)) { $new_products['products_name'] = tep_get_products_name($new_products['products_id']); $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a><br> '); $col ++; if ($col > 2) { $col = 0; $row ++; } } new contentBox($info_box_contents); ?> I simply removed the { $new_products_query = $rndChooser; } else and it worked!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.