[BETA] Sort Topics Alphabetically

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
User avatar
pentapenguin
Former Team Member
Posts: 11030
Joined: Thu Jul 01, 2004 4:15 am
Location: GA, USA

[BETA] Sort Topics Alphabetically

Post by pentapenguin »

MOD Title: Sort Topics Alphabetically
MOD Description: This MOD allows you to sort topics alphabetically within a forum.
MOD Version: 0.2.0

MOD Download: Download
Demo Board: http://www.pentapenguin.com/forum/viewforum.php?f=5 (click on S for best results)

Code: Select all

##############################################################
## MOD Title: Sort Topics Alphabetically
## MOD Author: pentapenguin < pentapenguin -@don't spam me@ bluebottle.com > (Jeremy Conley) http://www.pentapenguin.com
## MOD Description: This MOD allows you to sort topics alphabetically within a forum.
## MOD Version: 0.2.0
##
## Installation Level: Easy
## Installation Time: 10 Minutes
##
## Files To Edit: 3
## viewforum.php
## langauge/lang_english/lang_main.php
## templates/subSilver/viewforum_body.tpl
##
## Included Files: n/a
##
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
## Optional step: if you have CyberAlien's eXtreme Styles MOD (http://www.phpbb.com/phpBB/viewtopic.php?t=125251),
## you can copy the file in contrib/admin/xs_sort_topics_alphabetically.cfg to admin/xs_sort_topics_alphabetically.cfg and you will
## be automatically notified if there's an update available when you use the "check for updates" function. 
##
## This MOD is EasyMOD friendly! (http://area51.phpbb.com/phpBB/viewforum.php?sid=&f=17)
##
## For additional language and style downloads, please visit http://www.pentapenguin.com/forum/viewtopic.php?t=206
##
## To update to 0.2.0, see update_sort_topics_alphabetically_from_0.1.0_to_0.2.0.txt
##############################################################
## MOD History:
##   2005-11-15 - Version 0.2.0
##      - Fixed many bugs.
##      - Enabled better customization for more letters or letters in other non Latin based alphabets.
##
##   2004-11-10 - Version 0.1.0
##      - First Public Beta
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
Last edited by pentapenguin on Tue Nov 15, 2005 5:37 am, edited 1 time in total.
Support Resources: Support Request Template
If you need professional assistance with your board, please contact me for my reasonable rates.

Homeskillet
Registered User
Posts: 231
Joined: Thu Oct 07, 2004 5:00 am
Contact:

Post by Homeskillet »

Hi...I would love this MOD but I only need to have this option for one forum and not them all. Is there any simple way to modify the code so that it shows only in one forum or no?
...

User avatar
pentapenguin
Former Team Member
Posts: 11030
Joined: Thu Jul 01, 2004 4:15 am
Location: GA, USA

Post by pentapenguin »

Homeskillet wrote: Hi...I would love this MOD but I only need to have this option for one forum and not them all. Is there any simple way to modify the code so that it shows only in one forum or no?


Glad you like it!
Yes, you can. :)
The easiest thing to do would be to install CyberAlien's eXtreme Styles MOD that allows PHP in templates (which you should have installed anyway :D ).

Now get the ID number of the fourm you want this shown on (get the number after the f= like 2 -- viewforum.php?f=2).

Finally, just wrap the code in viewforum_body.tpl in PHP if() tags.
Like so:
<?php
global $forum_id;
if ($forum_id == fourm_id_number_here)
{
?>
<tr>
<td class="catBottom" align="center" valign="middle" colspan="6" height="28">
<span class="genmed"> {L_SORT_ALPHABETICALLY}: <a href="{U_ALL_TOPICS}" style="font-weight: bold; color: #FFF;">{L_ALL_TOPICS}</a> ||
<!-- BEGIN alphabetical_sort -->
<a href="{alphabetical_sort.U_LETTER}" style="font-weight: bold; color: #FFF;">{alphabetical_sort.LETTER}</a> {alphabetical_sort.DIVIDER}
<!-- END alphabetical_sort -->
</span>
</td>
</tr>
<?php
}
?>

Replace fourm_id_number_here with the ID number.
Hope this makes sense! :)
Support Resources: Support Request Template
If you need professional assistance with your board, please contact me for my reasonable rates.

Homeskillet
Registered User
Posts: 231
Joined: Thu Oct 07, 2004 5:00 am
Contact:

Post by Homeskillet »

Thank you so much. :D

That worked beautifully!!!

I have a "reviews" forum and wanted to be able to alphabetize the threads by band without having my whole board set up that way. Wonderful!!! :D

(Thanks for the tip on extreme styles. Just installed that with no problems too!)

*edit*

I may have spoke just a tad too soon....It appeared to work beautifully because I saw the A || B || etc...but when I clicked on a letter it did not do any sorting but kept the topics in date order.

Here's a link to the forum in question....
http://www.whatsonchristianrock.net/boa ... opicdays=0

If you need to see snippets of code just let me know. I'm sure I just missed something somewhere! Thanks :D
...

User avatar
pentapenguin
Former Team Member
Posts: 11030
Joined: Thu Jul 01, 2004 4:15 am
Location: GA, USA

Post by pentapenguin »

When I clicked on your link it said I have to register. ;)
Also, do you have other MODs installed on the viewforum.php page?
Support Resources: Support Request Template
If you need professional assistance with your board, please contact me for my reasonable rates.

Homeskillet
Registered User
Posts: 231
Joined: Thu Oct 07, 2004 5:00 am
Contact:

Post by Homeskillet »

Whoops! Sorry about that! :oops: Here's a test account for you:

user: testy
pass: testy


And here is a list of modifications I've made :oops: :

http://www.whatsonchristianrock.net/board

Default Template: subSilver
Other Templates Installed:
Athena
Charcoal
subBlack
subSilver
subVereor

MODS that have been installed:
All skins:
Country Flags (10/17/04)
No flood control for mod and admin(10/22/04)
Extended PM notification (10/26/04)
Now Playing(10/28/04)
Active Members Only (10/30/04)
PM Upon Registration (10/31/04)
Pro Forum Stats Mod(11/6/04)
Random User on index MOD (11/6/04)
Random Quote Hack(11/6/04)
Display Forum Description in viewforum (11/8/04)
Forum Rules Hack (11/9/04)
Disable editing/deleting of admin posts (11/9/04)
Last topic on index (11/11/09)
eXtreme Styles MOD (11/11/04)

Limited Skins:
Spelling Cow (subSilver and athena) (10/16/04)
Simply Merge (subsilver, subblack, subvereor)(10/23/04)
Offline/Online/Hidden Mod (subsilver, subblack, and Charcoal)(11/2/04)
Sort Topics Alphabetically (Reviews Forum Only) (Subsilver) (11/11/04)


Admin Only:
Easy Mod (10/16/04)
Disable Post Counts (10/25/04)
Admin Userlist (10/30/04)
Blank Page Template
Rank Image in ACP (11/9/04)
Admin email list (11/9/04)
Admin email search (11/9/04)
Prune Users (11/9/04)



Other Miscellaneous Modifications:
Changed Folder images on index to musical notes [subSilver theme only]
Edited includes/functions_post.php--removed the "edited by" line from administrator posts.
Administrators have no signature restrictions.
Added forum Icon to subvereor, subsilver, and subblack skins.
Edited search.php so that complete posts show when searching users posts.
Edited the following in langengmain.php
--view all emoticons>see all smilies
--says "please welcome our newest member" instead of "our newest member"
--emoticons>smilies
--added my email address to the board disable message
--changed random quote to say random verse
--changed random user to say "member of the moment"
--changed quote to say "Homeskillet said" instead of "homeskillet wrote"
Edited subsilver and subblack overall header to have a "listen now" link
...

Homeskillet
Registered User
Posts: 231
Joined: Thu Oct 07, 2004 5:00 am
Contact:

Post by Homeskillet »

Also, Somehow the A || B || , etc. still shows up on the bottom of viewforum in all other forums even though I thought I made it so that it would only be in forum id 45.. Really odd. I'm sure I just edited the code wrong. :oops: :?

I'm going to pm you my viewforum.php rather than post it because it's long.

Thanks for any help you can offer.
...

User avatar
pentapenguin
Former Team Member
Posts: 11030
Joined: Thu Jul 01, 2004 4:15 am
Location: GA, USA

Post by pentapenguin »

I looked at your viewforum.php code that you PMed me and it looks like you put the AND t.topic_title LIKE '$start_letter%' line in the wrong SQL query.
Remove it and put it in the next one.
Double check that and let me know. ;)
Support Resources: Support Request Template
If you need professional assistance with your board, please contact me for my reasonable rates.

Homeskillet
Registered User
Posts: 231
Joined: Thu Oct 07, 2004 5:00 am
Contact:

Post by Homeskillet »

That was it! Thank you :D
...

deadesq
Registered User
Posts: 3
Joined: Wed Nov 17, 2004 8:05 am

Bah! Can't get it to work

Post by deadesq »

Pentapenguin--I've tried three times to get this to work with my forum, and it's just refusing to work. How can I ask for your help or send you my viewforum.php file?

User avatar
pentapenguin
Former Team Member
Posts: 11030
Joined: Thu Jul 01, 2004 4:15 am
Location: GA, USA

Post by pentapenguin »

deadesq, I got your viewforum.php file.
1st problem: you put the SQL query in the wrong place.
Move it to the next SQL statement as said in the MOD install guide. ;)

2nd problem:
Somehow wierd characters got in the file at the bottom of the file.
Here the part you sent me:

Code: Select all

 //Start Sort Topics Alphabetically MOD 
 foreach ($letters as $val) 
 { 
 Ê Ê$template->assign_block_vars("alphabetical_sort", array( 
 Ê ÊÊ Ê'LETTER' => $val, 
 Ê ÊÊ Ê'U_LETTER' => append_sid("viewforum.php?f=$forum_id&start_letter=$val&topicdays=$topic_days"), 
 Ê ÊÊ Ê'DIVIDER' => ($val != 'Z') ? ' || ' : '', 
 Ê Ê)); 
 } 
 //End Sort Topics Alphabetically MOD 
Simply remove all of those Ê and it should work.
Let me know and good luck! :D
Support Resources: Support Request Template
If you need professional assistance with your board, please contact me for my reasonable rates.

deadesq
Registered User
Posts: 3
Joined: Wed Nov 17, 2004 8:05 am

Getting there....

Post by deadesq »

Okay, the query call issue is fixed, so no error is generated. However, the topics are still not alphabetizing--I get the letter links, but the topics are not alphabetical. Here's the forum:

http://www.deadesq.com/phpBB2/viewforum.php?f=3

Any ideas?

dave

User avatar
pentapenguin
Former Team Member
Posts: 11030
Joined: Thu Jul 01, 2004 4:15 am
Location: GA, USA

Post by pentapenguin »

Oh, you want them really sorted alphabetically! :lol:
I guess I might should slightly rename this MOD as I guess it more accurately groups posts by letter. ;)

But to get real alphabetical sorting, do this.
Open viewforum.php
Find:

Code: Select all

//Start Sort Topics Alphabetically MOD
$letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
$start_letter = ( isset($HTTP_GET_VARS['start_letter']) ) ? htmlspecialchars($HTTP_GET_VARS['start_letter']) : '';
$start_letter = str_replace("\'", "''", $start_letter);
//End Sort Topics Alphabetically MOD
Replace with:

Code: Select all

//Start Sort Topics Alphabetically MOD
$letters = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
$start_letter = ( isset($HTTP_GET_VARS['start_letter']) ) ? htmlspecialchars($HTTP_GET_VARS['start_letter']) : '';
$start_letter = str_replace("\'", "''", $start_letter);
$alphabetical_order_sql = ($start_letter != '') ? 't.topic_title DESC, ' : '';
//End Sort Topics Alphabetically MOD
Find:

Code: Select all

ORDER BY t.topic_type DESC, t.topic_last_post_id DESC 
Replace with:

Code: Select all

ORDER BY $alphabetical_order_sql t.topic_type DESC, t.topic_last_post_id DESC 
Hope this helps! :)
Support Resources: Support Request Template
If you need professional assistance with your board, please contact me for my reasonable rates.

deadesq
Registered User
Posts: 3
Joined: Wed Nov 17, 2004 8:05 am

Thanks for your help!

Post by deadesq »

Well, this didn't do it, either, which I'm sure is attributable to my utter ignorance of php, but I did find a mod that does exactly what I was trying to do:

http://www.phpbb.com/phpBB/viewtopic.php?t=147363

Thanks for all your help anyway, and when my forum topics get extensive enough, I will probably add in your mod for easier navigation!

User avatar
pentapenguin
Former Team Member
Posts: 11030
Joined: Thu Jul 01, 2004 4:15 am
Location: GA, USA

Post by pentapenguin »

Email me your viewforum.php file so I can take a look. :)
I know it works because I verified the code. ;)
Support Resources: Support Request Template
If you need professional assistance with your board, please contact me for my reasonable rates.

Post Reply

Return to “[2.0.x] MODs in Development”