Guest Posted January 14, 2004 Share Posted January 14, 2004 I want to change the look of the New products box, but not other boxes that use the same class. The new product box uses the class "infobox" and I want it to use a new class "infobox2" However I cant find out exactly where the class is called, im guessing its in includes/classes/boxes.php however I cant change this as I need to use it for other boxes. So how can I call another class instead? I could copy and rename the includes/classes/boxes.php to something else, but what would I need to change within that file and what would I need to change within includes/modules/newproducts.php to call the new class? I hope that makes sense, im a bit stuck on this! Link to comment Share on other sites More sharing options...
Guest Posted January 15, 2004 Share Posted January 15, 2004 I was wondering if anyone can help me out on this? Link to comment Share on other sites More sharing options...
paulm2003 Posted January 15, 2004 Share Posted January 15, 2004 However I cant find out exactly where the class is called, im guessing its in includes/classes/boxes.php however I cant change this as I need to use it for other boxes. Hi, inside boxes.php you can copy the classes used by new_products.php , edit (and rename) the copied class as you like, and edit new_products.php to call the new classes you just made. (so don't copy the whole boxes.php file) I was working on something simular to make it possible to assign CSS styles to some of the table headings. It might be helpfull to you to, allthough it does influence more boxes than you asked. Instead of creating a new box class, I editted one a bit to assign a CSS class to the box headings. Tiny box class update 2004/01/06 Assign CSS class to the (a.o.?) "New Products For January" and "Also Purchased" table heading (generated by "catalog/includes/modules/new_products" and "also_purchased_products.php") Makes it possible/easyer to assign CSS styles to these table headings Copy the included file over the original or do it manually: Changes to "catalog/includes/classes/boxes.php": 1) around line 148-151 change: class contentBoxHeading extends tableBox { function contentBoxHeading($contents) { $this->table_width = '100%'; to: class contentBoxHeading extends tableBox { function contentBoxHeading($contents) { $this->table_parameters = 'class="contentBoxHeadingBTS"'; // added BTS 2004/01/06 $this->table_width = '100%'; Don't mind the BTS stuff and other text, it is just a fast copy of a little piece of experimental code. hope it helps a bit Link to comment Share on other sites More sharing options...
Guest Posted February 6, 2004 Share Posted February 6, 2004 I still cant get this to work :( Im now using the featured product mod, here is the code <?php/* osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2002 osCommerce Released under the GNU General Public License Featured Products V1.1 Displays a list of featured products, selected from admin For use as an Infobox instead of the "New Products" Infobox */ ?> <!-- featured_products //--> <?php if(FEATURED_PRODUCTS_DISPLAY == 'true') { $featured_products_category_id = $new_products_category_id; $cat_name_query = tep_db_query("select categories_name from categories_description where categories_id = '" . $featured_products_category_id . "' limit 1"); $cat_name_fetch = tep_db_fetch_array($cat_name_query); $cat_name = $cat_name_fetch['categories_name']; $info_box_contents = array(); if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) { $info_box_contents[] = array('align' => 'left', 'text' => '<a class="headerNavigation" href="' . tep_href_link(FILENAME_SPECIALS) . '">' . TABLE_HEADING_FEATURED_PRODUCTS . '</a>'); list($usec, $sec) = explode(' ', microtime()); srand( (float) $sec + ((float) $usec * 100000) ); $mtm= rand(); $featured_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand($mtm) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS); } else { $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name)); $featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.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 left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS); } $row = 0; $col = 0; $num = 0; while ($featured_products = tep_db_fetch_array($featured_products_query)) { $num ++; if ($num == 1) { new contentBoxHeading($info_box_contents); } $featured_products['products_name'] = tep_get_products_name($featured_products['products_id']); if($featured_products['specstat']) { $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=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br><s>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($featured_products['specials_new_products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</span>'); } else { $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=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id']))); } $col ++; if ($col > 1) { $col = 0; $row ++; } } if($num) { new contentBox($info_box_contents); } } else // If it's disabled, then include the original New Products box { include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); } ?> <!-- featured_products_eof //--> So what do I need to change in the above? More importantly what do I need to change or copy in the boxes file? I only want this one box to look different and it is driving me mad. Can anyone help? Link to comment Share on other sites More sharing options...
paulm2003 Posted February 6, 2004 Share Posted February 6, 2004 Hi hotnuts21, I agree that the box class is a real pain, allthough it probably is programmed very well. If you don't really know oo programming (like me) it can give you a real headache. if($num) { new contentBox($info_box_contents); } } else // If it's disabled, then include the original New Products box { include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); } ?> <!-- featured_products_eof //--> So what do I need to change in the above? More importantly what do I need to change or copy in the boxes file? What you need to do depends on what you exactly want to change. If you can do the changes you want through the stylesheet I think you should change the above code like this: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ While writing this post I came to another possible approach (tested it on a simular box and it does work), if you like it you can ignore the text below the *** : Wrap this line (featured products code): new contentBox($info_box_contents); into a div like this: echo '<div id="featuredProducts">' new contentBox($info_box_contents); echo '</div>' now this table will have a div around it with an unique CSS id, so if you know CSS you must be able to style it independant of the other boxes. ************************************************************************ (Ignore this if the above works for you) Or change: new contentBox($info_box_contents); to (for example): new contentBoxNew($info_box_contents); after that open the box class file (includes/classes/boxes.php), and find this: class contentBox extends tableBox { function contentBox($contents) { $info_box_contents = array(); $info_box_contents[] = array('text' => $this->contentBoxContents($contents)); $this->table_cellpadding = '1'; $this->table_parameters = 'class="infoBox"'; $this->tableBox($info_box_contents, true); } then you can use this code to generate a new box class, so you copy the above code and paste it right behind it like this: class contentBox extends tableBox { function contentBox($contents) { $info_box_contents = array(); $info_box_contents[] = array('text' => $this->contentBoxContents($contents)); $this->table_cellpadding = '1'; $this->table_parameters = 'class="infoBox"'; $this->tableBox($info_box_contents, true); } class contentBox extends tableBox { function contentBox($contents) { $info_box_contents = array(); $info_box_contents[] = array('text' => $this->contentBoxContents($contents)); $this->table_cellpadding = '1'; $this->table_parameters = 'class="infoBox"'; $this->tableBox($info_box_contents, true); } Now you have two the same box classes so you have to change one to be different like this: class contentBoxNew extends tableBox { function contentBox($contents) { $info_box_contents = array(); $info_box_contents[] = array('text' => $this->contentBoxContents($contents)); $this->table_cellpadding = '1'; $this->table_parameters = 'class="infoBoxNew"'; $this->tableBox($info_box_contents, true); } So the name of the new class has changed to contentBoxNew (same name as in the featured box) and I changed 'class="infoBox"' to 'class="infoBoxNew"'. Maybe it is confusing that there are two different types of classes involved, the PHP class "contentBoxNew" and the CSS class "infoBoxNew". Anyway, after doing the above you should be able to assign different CSS styles to this box (or at least ot the "infoBoxContents" part of it). I hope you know how to style through the stylesheet and that it is what you are looking for, otherwise the whole story is useless I am afraid. Paul Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.