PDA

View Full Version : Reorganize Subscribed Forums by Numerical Order Instead Of Alphabetical Order


larryd
05-26-2002, 08:21 AM
Ive been toying around tonight with creating a new page called favorites.php that will allow me to display just the forums that Ive maked as the ones I want to suscribe to with a little bit of other basic information. Basically I reworked the usercp page, the only problem Im running into is that the forums are showing up in alphabetical format and thats not what i want, I want them to show up in the order they are displayed on the index.php file.. What do I have to change to do this? Here is the code for it



// ############################### start subscribed forums ###############################
$forums=$DB_site->query("SELECT * FROM forum,subscribeforum WHERE subscribeforum.forumid=forum.forumid AND userid=$bbuserinfo[userid] ORDER BY title");
$totalforums=$DB_site->num_rows($forums);

$forumbits = '';
if ($totalforums>0) {
while ($forum=$DB_site->fetch_array($forums)) {

$forumperms=getpermissions($forum[forumid]);
if (!$hideprivateforums) {
$forumperms[canview]=1;
}
if ($forumperms[canview]) {
$forumshown=1;

// do light bulb
if ($bbuserinfo[lastvisitdate]=="Never") {
$forum[onoff]="on";
} else {
if (isset($bbforumview[$forum['forumid']]) and $bbforumview[$forum['forumid']]>$bbuserinfo['lastvisit']) {
$userlastvisit=$bbforumview[$forum['forumid']];
} else {
$userlastvisit=$bbuserinfo['lastvisit'];
}
if ($userlastvisit<$forum['lastpost']) {
$forum[onoff]="on";
} else {
$forum[onoff]="off";
}
}

if ((!$forumperms['canpostnew'] and $showlocks) or $forum['allowposting']==0) {
$forum[onoff].="lock";
}

// prepare template vars
if (!$showforumdescription) {
$forum[description]="";
}

// dates
if ($forum[lastpost]>0) {
$forum[lastpostdate]=vbdate($dateformat,$forum[lastpost]);
$forum[lastposttime]=vbdate($timeformat,$forum[lastpost]);
eval("\$forum[lastpostinfo] = \"".gettemplate("forumhome_lastpostby")."\";");
} else {
$forum[lastpostinfo]="Never";
}

eval("\$forumbits .= \"".gettemplate("favorites_forumbit")."\";");

} // if can view
} // while forums

eval("\$forumlist = \"".gettemplate("usercp_forums")."\";");

} else {
eval("\$forumlist = \"".gettemplate("usercp_noforums")."\";");
}



if you want to see exactly what im talking about the page is located here

http://www.newcelica.org/forums/favorites.php?s=

Im still gonna change a few other things but the biggest thing I want to change is the display order of the forums from alphabetical to numercial.. thanks in advance guys..

Dark_Wizard
05-26-2002, 09:52 AM
Change this >> ORDER BY title << to what you need....could be id etc....

larryd
05-26-2002, 10:02 AM
but what is the column name if its not title.. im not familair with the dbase setup

Admin
05-26-2002, 10:29 AM
<font face="Courier">ORDER BY forum.forumid</font>

larryd
05-26-2002, 10:38 AM
close but now i got a nother issue.. that did arrange them by forum id, but thats not the way there displayed on the main page, on the main page there displayed by Forum Order which is specified in the forum control panel.. can i do the same here?

Admin
05-26-2002, 10:41 AM
That would be more complicated I'm afraid.

larryd
05-26-2002, 10:43 AM
yeah i figured as much, I dont understand why it has to be so complex.. I mean I can figure out the logic

go through the forums the same way the main page does and display them in display order and only show them if its marked as a favorite.. this would be a nice hack if I could figure out this one last thing ;)

Dark_Wizard
05-26-2002, 10:45 AM
Why not ORDER BY forum.displayorder

larryd
05-26-2002, 10:47 AM
wow.. that was simple.. that worked.. I just didnt know the right identifier.. AWESOME.. thanks everyone ;) I might compile this whole mess up nicer and release it as a hack ;)

Admin
05-26-2002, 10:49 AM
Originally posted by Dark_Wizard
Why not ORDER BY forum.displayorder
Because displayorders gets reset under each category.

See the screenshot if you don't understand. :)

larryd
05-26-2002, 10:51 AM
but it works if yers is setup like mine is.. which the #s just get higher as you go down the list starting at 100

Dark_Wizard
05-26-2002, 11:50 AM
Originally posted by FireFly

Because displayorders gets reset under each category.

See the screenshot if you don't understand. :)

Agreed, but doesn't it look at the parentid first?

Admin
05-26-2002, 11:55 AM
It does on index.php, but it doesn't work that way in usercp.php -- which is why I said it would be more complicated.

Dark_Wizard
05-26-2002, 11:57 AM
Originally posted by FireFly
It does on index.php, but it doesn't work that way in usercp.php -- which is why I said it would be more complicated.
I just noticed that after I posted....