Guest Denver Dave Posted September 9, 2005 Share Posted September 9, 2005 When adding or editing a product there is a dropdown box to select the category. Unfortunately the items are sorted in category id number order and not in order of the category path making it very difficult to find the selections that we want if we have very many categories. I've located the code that populates the dropdown box, and it appears that we have to build an array with the category path first before building the select options, but I'm not sure of the code to do that. Here is the existing code: <select name="cat_id" class="textbox"> <?php for ($i=0; $i<count($categoryArray); $i++){ ?> <option value="<?php echo $categoryArray[$i]['cat_id']; ?>" <?php if(isset($results[0]['cat_id']) && $categoryArray[$i]['cat_id']==$results[0]['cat_id']) { echo "selected='selected'"; } ?>><?php echo getCatDir($categoryArray[$i]['cat_name'],$categoryArray[$i]['cat_father_id'], $categoryArray[$i]['cat_id']); ?></option> <?php } ?> </select> Seems like everyone with very many categories would want the dropdown box sorted in an order where they can find the category path that they want. Any help appreciated - thanks =================== I'm sure others will know better, more efficient ways - but I just had to have the categories in some kind of order - here is how I did it - improvements appreciated: <!-- **** davehack comment category select box here **** --> <?php for ($i=0; $i<count($categoryArray); $i++) { $cat_sorted[$categoryArray[$i]['cat_id']]= getCatDir($categoryArray[$i]['cat_name'],$categoryArray[$i]['cat_father_id'], $categoryArray[$i]['cat_id']); } asort($cat_sorted); ?> <select name="cat_id" class="textbox"> <?php foreach ($cat_sorted as $cat_id => $cat_dir) { ?> <option value="<?php echo $cat_id; ?>" <?php if(isset($results[0]['cat_id']) && $cat_id==$results[0]['cat_id']) echo "selected='selected'"; ?> ><?php echo $cat_dir; ?></option> <?php } ?> </select> <?php /* hacked code replaced <select name="cat_id" class="textbox"> <?php for ($i=0; $i<count($categoryArray); $i++){ ?> <option value="<?php echo $categoryArray[$i]['cat_id']; ?>" <?php if(isset($results[0]['cat_id']) && $categoryArray[$i]['cat_id']==$results[0]['cat_id']) { echo "selected='selected'"; } ?>><?php echo getCatDir($categoryArray[$i]['cat_name'],$categoryArray[$i]['cat_father_id'], $categoryArray[$i]['cat_id']); ?></option> <?php } ?> */ ?> Quote Link to comment Share on other sites More sharing options...
Guest Denver Dave Posted September 10, 2005 Share Posted September 10, 2005 Here is the "fix" for the initial admin product list. Might as well give it some sort instead of making the admin user sort the display every friggin time they do a "fresh" display: Any improvements appreciated: if(isset($_GET['orderCol']) && isset($_GET['orderDir'])){ $orderBy = $glob['dbprefix']."CubeCart_inventory.".$_GET['orderCol']." ".$_GET['orderDir']; } else { // ************* davehack for initial product list order ********** // $orderBy = $glob['dbprefix']."CubeCart_inventory.productId ASC"; $orderBy = $glob['dbprefix']."CubeCart_inventory." . 'name ASC'; Quote Link to comment Share on other sites More sharing options...
Guest megagente Posted September 23, 2005 Share Posted September 23, 2005 for the customer? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.