![]() |
Reorder User Ranks
I have added about a dozen user ranks in my acp and they are working fine. However, on a user's post, when it shows the ranks, it does not list them in the order I have them entered. The way I have it setup, a user can have multiple rankings (eg. Administrator, over 300 posts, etc).
What determines the order the ranks are shown in? How do I force the system to list ranks in a particular order? Is there a mod out there that allows me to do this? I searched, but did not find anything. |
Anybody? Anybody?
|
I think you need to actually change the code. It looks like this is done in includes/functions_ranks.php at the very bottom where it says "Begin Build Ranks PHP Code function"
|
The problem is that I am not a programmer. I have no idea how to do that. Is there anybody that can give me the "find this, replace with this" instructions?
|
Sorry, I can't tell you exactly. I'm a trial and error coder and I don't have enough ranks on my test site to be able to test this out myself.
|
Well, if it is a test site, can't you just make more ranks? You can also use my test site if you wish.
In the function is the line that says "ORDER BY ranks.usergroupid DESC, minposts DESC". Obviously, it is displaying the ranks by usergroup id. However, not being a programmer, I am just guessing here, but if we add a new column to the ranks table in the database and then connect it to the ranks area of the acp for "display order" we can then change that line to "ORDER BY ranks.displayorderid DESC, minposts DESC" or something like this. Am I right? For simplicity sake, can I change the line to something that just replaces "usergroupid" with the rankid? or even list the rank ids in the order I want them displayed? |
The ranks table has a field called rankid. So yes, you can order by rank.rankid . You can always try that and see. If it doesn't work, then you go back to default (just keep a copy). I think after you change it in the code, you will need to go to the Ranks area in the Admin CP and Save something to get it to rebuild the ranks list.
If you were to write a modification for this, you would probably want to add a column for order. Then you could order by rank.order. And I don't want to add more ranks to my test site because I'm trying to keep it as close to my live site as possible since I want to make the big jump from 3.6 to 3.8 as soon as it goes Gold. |
Well, knowing that I want to add a rank.order option in the acp and being able to actually do it are two different things. I will wait to see if anybody can do this for me.
Do you know the mysql command to add a column to an existing table? |
I just add them in phpMyAdmin. But, I did write a product that I shared with someone and this is the query I used to add a new column to the thread table:
Code:
$db->query("ALTER TABLE " . TABLE_PREFIX . "thread ADD verify_status SMALLINT(5) UNSIGNED DEFAULT '0' NOT NULL"); If you go for this approach of adding a new 'order' column, don't forget you need to modify the /admincp/ranks.php page to include it on your User Rank page in the Admin CP |
That looks like the command to add to a php file. What is the command I use in phpMyAdmin?
|
In phpMyAdmin you just go to the table and after it lists all the columns, it says:
Add 1 fields(s) The 1 is in an input box. At End of Table is the default, click on Go and fill in the information. I would strongly suggest you do this on your test site before you do it on a live site. |
Got it and done. Thank you for your help. At least this way I can manually change the order, that is, until a hack is written.
--------------- Added 08 Dec 2008 at 13:12 --------------- Well, I created a new column in my "ranks" table named "order_id". I then modified the "functions_ranks.php" file and changed the bottom section from Code:
// #################### Begin Build Ranks PHP Code function ################ Code:
// #################### Begin Build Ranks PHP Code function ################ I went to the "Update Counters" area in the ACP and updated the titles and ranks. It is still displaying the same way. Ideas? |
Well, it turns out that when I made that minor change and added the new column to the database, it broke the ranking system. Everybody had ranks that were not their own. In other words, we suddenly had tons of people that showed rankings that are only earned from a specified amount of posts. There is no way they should have that rank. When I removed the DB column and undid the minor changes I made to the file, it all reverted to working properly.
I don't get it. Ideas? |
My guess is it's a datastore issue. You probably need to add the column to the rank array in order for it to get used. Look at ranks.php around line 174 where the array is assigned. I'll bet you 'broke' things by not adding the column in there and putting it all in there.
|
The rank array code looks like
$ranks = array( 'ranklevel' => 1, 'usergroupid' => -1, 'minposts' => 10, 'rankimg' => 'images/', ); How do I add a reference to the new table column "order_id"? |
All I did was order it by rankid. I added my ranks in a certain order so the rankid was all I needed.
Code:
$ranks = $vbulletin->db->query_read_slave(" |
|
All times are GMT. The time now is 11:43 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|