Author Topic: Mod Request: block sub categories in dropdown category list  (Read 10917 times)

0 Members and 1 Guest are viewing this topic.

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Mod Request: block sub categories in dropdown category list
« on: April 30, 2003, 06:35:35 PM »
Is there already a mod that will do this?  I tried searching but was totally overwhelmed with a list of over 450 threads.

Basically what I would like to do is for the category dropdown list, is to only show the main categories and not the subcategories.

I have my system setup like

A (main category)
-Anton (sub category of A)
-Adam
B (main category)
-Betty (Sub category of B)
-Brian
ETC.
ETC.
ETC.

I want only to show the main categories (ie.  A B C D E F G H  etc).  For me the busier the site gets and the more users it gets, the larger that dropdown category list gets.  I'd rather the users click on the letter that is their usernames beginning letter then let them see all the subcategories that are displayed on the regular category page for that letter.

Is this possible?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Mod Request: block sub categories in dropdown category list
« Reply #1 on: April 30, 2003, 06:43:54 PM »
it was easier then I thought... :D
in /includes/functions.php
1.
find:
Code: [Select]
       $category_list .= " class=\"dropdownmarker\"";
      }

delete the } bracket.

2.
then, find:
Code: [Select]
     $category_list .= get_category_dropdown_bits($cat_id, $category_id, $depth + 1);
add right after } bracket, so it should be like this:
Code: [Select]
     $category_list .= get_category_dropdown_bits($cat_id, $category_id, $depth + 1);
}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Mod Request: block sub categories in dropdown category list
« Reply #2 on: April 30, 2003, 07:02:16 PM »
another way, if want dont show sub-cats for only your "members" category, then instead of removing } in step 1. add this:
Code: [Select]
     if ($cat_cache[$category_id]['cat_parent_id'] != XXXX) {
where XXXX is number you "members" category
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Mod Request: block sub categories in dropdown category list
« Reply #3 on: April 30, 2003, 07:14:25 PM »
Thanks, that will work for now. But I guess I screwed up what I was actually looking for.

In reality I should have put
User Galleries (This is the main category)
-A (This is a subcategory and should also show)
--Adam (This is a subcategory of A and should NOT show)
-B (This is a subcategory of User Galleries and should show)
--Betty (This is a sub category of B and should NOT show)
Etc etc etc.

While what you posted will work for now, the users just have to click on
User Galleries then they are shown the page with all the alphabet, A-Z they then click on the letter corresponding to their first letter in their username, then they are shown a list of all users that have that first letter, then they click on their own gallery.

Im trying to make this so that
1. The category drop down list doesnt get huge with every category (on my system every user has their own category)
2. So that they can easily get to their own category.
3. So that on the home page, under the Categories area, I dont want it to list A - Z as seperate categories, thats why I put them under User Galleries else they would all show up on the home page as 26 different categories which would be too large.

Im wondering if the depth marker can be changed in functions.php to do like what I post here.

Still, thanks for the info I appreciate your time very much.

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Something got messed up with your first response
« Reply #4 on: April 30, 2003, 07:28:30 PM »
Now my User Galleries in the dropdown list doesnt works properly.
My second main category is called Assignments and my third main category is called News and Updates

So when I choose User Galleries it takes me to the alphabetical listing, but when I choose Assignments it takes me to the first sub category of User galleries, Namely category A.
When I choose the 3rd main category, that of news, it takes me to the assignments category.

So I checked the html coding on the page and this is what I've found:
Code: [Select]
<select name="cat_id" onchange="if (this.options[this.selectedIndex].value != 0){ forms['jumpbox'].submit() }" class="categoryselect">
<option value="0">Select category</option>

<option value="0">-------------------------------</option>
<option value="30" class="dropdownmarker">Users Galleries</option>
<option value="31" selected="selected"
<option value="32"
<option value="33"
<option value="34"
<option value="35"
<option value="36"
<option value="37"
<option value="38"
<option value="39"
<option value="40"
<option value="41"
<option value="42"
<option value="43"
<option value="44"
<option value="45"
<option value="46"
<option value="47"
<option value="48"
<option value="49"
<option value="50"
<option value="51"
<option value="52"
<option value="53"
<option value="54"
<option value="55"
<option value="56"
<option value="26" class="dropdownmarker">Assignments</option>
<option value="27"<option value="15" class="dropdownmarker">News Updates</option>
</select>


The changes I made to the functions.php is shown below:
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 .= "<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;
}


Did I move the } somewhere wrong?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Mod Request: block sub categories in dropdown category list
« Reply #5 on: April 30, 2003, 07:45:49 PM »
yes, u are right...my bad  :oops:
here is fixed function:
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)) {
      if ($cat_cache[$category_id]['cat_parent_id'] == 0) {
      $category_list .= "<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;
}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Mod Request: block sub categories in dropdown category list
« Reply #6 on: May 02, 2003, 07:49:31 PM »
Found a problem with this mod:
When in the admin panel, and you want to make a subcategory of a main category, it wont allow it.

That is to say that it only lists the main categories, so if I have
User Galleries
-A
-B
-C
etc, and I want to place a new gallery like
-C
--Chris
it's disabled in the dropdown box and you can't move it around using the up and down arrows.

Anyway to only do the mod you posted so that it shows up in the site and not on the admin panel too?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Mod Request: block sub categories in dropdown category list
« Reply #7 on: May 03, 2003, 12:31:55 AM »
Quote from: lakeside
Anyway to only do the mod you posted so that it shows up in the site and not on the admin panel too?

yes, I noticed that too...unfortunetly both ACP and rest of the site uses same function...
u can create a fixed dublicate function, with different name, but then u have to go through the .php files and search where to change to use new function...that's pain...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Mod Request: block sub categories in dropdown category list
« Reply #8 on: May 03, 2003, 04:45:33 AM »
Okay, I'll take a look and see if I can do that.  Currently Im just opening up the phpmysql and changing the parent category number until I can get this done.

Thanks,

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Mod Request: block sub categories in dropdown category list
« Reply #9 on: May 03, 2003, 06:42:27 AM »
Quote from: lakeside
Currently Im just opening up the phpmysql and changing the parent category number until I can get this done.

ouch  8O
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Mod Request: block sub categories in dropdown category list
« Reply #10 on: May 03, 2003, 07:04:16 AM »
:lol:  hehehehe, actually I meant that while Im pretty good at phpmysql, Im currently finding that its easier to open up phpmysql to edit the parent category then it is to edit the scritps.  (Hmmmm something said here)

;)