Plascual Posted March 14, 2006 Posted March 14, 2006 Could anybody knows how to add a "Parent Category" button to catalog.php ? It would be placed near subcategorie image (or replace it) and would link to the parent category. I think it could also be added to contributions! I can help, I don't know how to do it properly... Thanks in advance! Plascual
user99999999 Posted March 14, 2006 Posted March 14, 2006 I think its better to create the category where you want it and then move any categories you want to the new one.
Plascual Posted March 14, 2006 Author Posted March 14, 2006 I think its better to create the category where you want it and then move any categories you want to the new one. I would like a button that let the users get "up one level" in the categories... so: Top-Category1 ----------------- --->Subcategory1 --->Subcategory2 ------>Subcategory1 ------>Subcategory2 --->Subcategory3 If I'm into SubCategory1 of SubCategory2, then this button would bring me to SubCategory2. If I'm into SubCategory3 of Top-Category1, then this button would bring me to Top-Category 1. Is there any contribution that does this?
Plascual Posted March 14, 2006 Author Posted March 14, 2006 I found this function in "includes/functions/general.php" : // Recursively go through the categories and retreive all parent categories IDs // TABLES: categories function tep_get_parent_categories(&$categories, $categories_id) { $parent_categories_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$categories_id . "'"); while ($parent_categories = tep_db_fetch_array($parent_categories_query)) { if ($parent_categories['parent_id'] == 0) return true; $categories[sizeof($categories)] = $parent_categories['parent_id']; if ($parent_categories['parent_id'] != $categories_id) { tep_get_parent_categories($categories, $parent_categories['parent_id']); } } } How may I use this function for a "Parent Category" button ?
Guest Posted March 14, 2006 Posted March 14, 2006 you have already that from the breadcrump at the top. So you could just change to breadcrumb links to buttons. Or you can move it to someplace else in the catalog.
user99999999 Posted March 14, 2006 Posted March 14, 2006 Here is a breadcrumb mod for admin http://www.oscommerce.com/community/contributions,4093
Plascual Posted March 15, 2006 Author Posted March 15, 2006 Thank you infinitely for all your help! you have already that from the breadcrump at the top. So you could just change to breadcrumb links to buttons. Or you can move it to someplace else in the catalog. Finally, this did the trick! I created another function in breadcrumb.php, where I identify the parent category to create de link... function uplevel($separator = ' - ') { $trail_string = ''; $n=sizeof($this->_trail)-2; //subtract 2 to get the parent category if (isset($this->_trail[$n]['link']) && tep_not_null($this->_trail[$n]['link'])) { $trail_string .= '<a href="' . $this->_trail[$n]['link'] . '">' . tep_image_button('button_uplevel.gif', IMAGE_BUTTON_UPLEVEL) . '</a>'; } return $trail_string; } And I can call it where I want with this code: <? echo $breadcrumb->uplevel(' ? '); ?> Do you think it could be optimized a little more?
methodprobiz Posted May 25, 2006 Posted May 25, 2006 Hmm... when I tried this, and clicked the button, it just took me back to the main catagory page. I placed the call within the products_new.php - I am having Such a hard time simply calling a parent catagory of any product. I hope someone can help? Is there a special place within the breadcrumb.php that you have placed this? --aside from before the closing }'s Thank you infinitely for all your help! Finally, this did the trick! I created another function in breadcrumb.php, where I identify the parent category to create de link... function uplevel($separator = ' - ') { $trail_string = ''; $n=sizeof($this->_trail)-2; //subtract 2 to get the parent category if (isset($this->_trail[$n]['link']) && tep_not_null($this->_trail[$n]['link'])) { $trail_string .= '<a href="' . $this->_trail[$n]['link'] . '">' . tep_image_button('button_uplevel.gif', IMAGE_BUTTON_UPLEVEL) . '</a>'; } return $trail_string; } And I can call it where I want with this code: <? echo $breadcrumb->uplevel(' ? '); ?> Do you think it could be optimized a little more?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.