Author Topic: Bug in dropdown function?  (Read 5291 times)

0 Members and 1 Guest are viewing this topic.

Offline Harry

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • http://7summits.com
Bug in dropdown function?
« on: July 17, 2002, 09:01:35 AM »
Hello Jan & Nicky,

While working on getting the  templates right for my site I noticed that there is a problem with the dropdown list of categories (jump buttons)

I cleaned out the My Sql and did a new install, but the problem remains ( I did not re-upload the programfiles as I changed some of them, but none of the dropdown files)

Anyway after adding a 1st category (Kilimanjaro) the dropdown list looks like this:


You can not choose for the category, the name of the category seems switched somehow with the text next to the option?

When I add a 2nd category, the dropdown in the admin panel has the same problem:

So I cannot choose to create a subdirectory under the 1st category

So I add it as a new category, bu then the dropdown list (home) looks like this:

The top drowdown is teh same, a new on is added as shown.

Is this a bug?
Where should I look for the code?

This is the code I could find in functions.php, bu tdo not know if this is the problem:

Code: [Select]
function get_category_dropdown_bits($cat_id, $cid = 0, $depth = 1) {
  global $site_db, $drop_down_cat_cache, $cat_cache;

  if (!isset($drop_down_cat_cache[$cid])) {
    return "";
  }
  $category_list = "";
  foreach ($drop_down_cat_cache[$cid] as $key => $category_id) {
    if (check_permission("auth_viewcat", $category_id)) {
      $category_list .= "<select>
<option value=\"".$category_id."\"";
      if ($cat_id == $category_id) {
        $category_list .= " selected=\"selected\"";
      }
      if ($cat_cache[$category_id]['cat_parent_id'] == 0) {
        $category_list .= " class=\"dropdownmarker\"";
      }

      if ($depth > 1) {
        $category_list .= ">".str_repeat("--", $depth - 1)." ".$cat_cache[$category_id]['cat_name']."</option>\n";
      }
      else {
        $category_list .= ">".$cat_cache[$category_id]['cat_name']."</option>\n";
      }
      $category_list .= get_category_dropdown_bits($cat_id, $category_id, $depth + 1);
    }
  }
  unset($drop_down_cat_cache[$cid]);
  return $category_list;
}

function get_category_dropdown($cat_id, $jump = 0, $admin = 0, $i = 0) {
  global $lang, $drop_down_cat_cache, $cat_parent_cache;
  // $admin = 1  Main Cat (update/add cats)
  // $admin = 2  All Cats (find/validate images...)
  // $admin = 3  Select Cat (update/add image)
  // $admin = 4  No Cat (check new images)

  switch ($admin) {
  case 1:
    $category = "\n
</select><select name=\"cat_parent_id\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['main_category']."</option>\n";
    $category .= "<option value=\"0\">--------------</option>\n";
    break;

  case 2:
    $category = "\n
</select><select name=\"cat_id\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['all_categories']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    break;

  case 3:
    $i = ($i) ? "_".$i : "";
    $category = "\n
</select><select name=\"cat_id".$i."\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['select_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    break;

  case 4:
    $category = "\n
</select><select name=\"cat_id\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['no_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    break;

  case 0:
  default:
    if ($jump) {
      $category = "\n
</select><select name=\"".URL_CAT_ID."\" onchange=\"if (this.options[this.selectedIndex].value != 0){ forms['jumpbox'].submit() }\" class=\"categoryselect\">\n";
    }
    else {
      $category = "\n
</select><select name=\"".URL_CAT_ID."\" class=\"categoryselect\">\n";
    }
    $category .= "<option value=\"0\">".$lang['select_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
  } // end switch

  $drop_down_cat_cache = array();
  $drop_down_cat_cache = $cat_parent_cache;
  $category .= get_category_dropdown_bits($cat_id);
  $category .= "</select>\n";
  return $category;
}


(I have not changed anything in here)

Thanks in advance for your help,


best regards
Trips & Expeditions to the 7 summits: the highest mountains on the seven continents. Kilimanjaro, Aconcagua and more!
Check out http://7summits.com

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Bug in dropdown function?
« Reply #1 on: July 17, 2002, 10:15:20 AM »
Can you give us a link to see this in action?

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Harry

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • http://7summits.com
Bug in dropdown function?
« Reply #2 on: July 17, 2002, 10:26:04 AM »
Quote from: Jan Sorgalla
Can you give us a link to see this in action?

Greets Jan


Hi Jan, just sent it you by email,

thanks,

Harry
Trips & Expeditions to the 7 summits: the highest mountains on the seven continents. Kilimanjaro, Aconcagua and more!
Check out http://7summits.com

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Bug in dropdown function?
« Reply #3 on: July 17, 2002, 10:39:13 AM »
Ok, i see. The PHP Code for the functions you posted above is not original one. Maybe you opened it in a HTML-Editor who corrupted the code. Replace "includes/functions.php" with the originla one and try it again.

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Harry

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • http://7summits.com
Bug in dropdown function?
« Reply #4 on: July 17, 2002, 10:52:21 AM »
Quote from: Jan Sorgalla
Ok, i see. The PHP Code for the functions you posted above is not original one. Maybe you opened it in a HTML-Editor who corrupted the code. Replace "includes/functions.php" with the originla one and try it again.

Greets Jan


YAAM (Yet Another Aha Moment) :wink:

Thanks, that seems to work, normally I open the php files with Notepad, but must have done it with Frontpage once (which _is_ useful for the Template files) and it immediatly begins 'fixing' what is not broken... :roll:

Thanks for the quick and good support,
best regards,

Harry
Trips & Expeditions to the 7 summits: the highest mountains on the seven continents. Kilimanjaro, Aconcagua and more!
Check out http://7summits.com