phpBB.com     phpBB Academy     phpBB Modders     phpBB Weekly     ktuk     phpBB Hacks     Vlad Studio  

Static Topics

Change the way that topics are ordered in your forum(s)

Not enough for a full proper MOD, but too useful not to share
Forum rules
Please read over our forum guidelines

Static Topics

Postby kenny » 02 Jul 2008, 01:29

These 2 little code snippets allow you to change the way topics are ordered in your forums.
The 1st snippet changes all forums and the 2nd allows you to customise which forums stay static.
By static, I mean the order in which the topics were created - topic_time

Code: Select all
Snippet 1
---------

OPEN: viewforum.php

FIND:
-----
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');

REPLACE WITH:
-------------
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');

Code: Select all
Snippet 2
---------

OPEN: viewforum.php

FIND:
-----
$sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');

REPLACE WITH:
-------------
$static_forums = array("1", "2", "3"); // replace 1, 2, 3 with your forum ID's. Add/remove as necessary

if (in_array($forum_id, $static_forums))
{
   $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');
}
else
{
   $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views');
}

You can add/remove forum id's as necessary
Last edited by kenny on 27 Aug 2009, 09:04, edited 2 times in total.
Reason: Updated code - see latest post for details
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Donate to 6 String MODs
If you like any of the work that I do here, please consider donating.
click the image on the left for a list of some of the advantages of donating



Re: Static Topics

Postby kenny » 03 Jul 2008, 09:29

Updated the code for Snippet 2 - little bit more efficient :P
Code: Select all
This code has now been updated in the 1st post - please see the 1st post for the updated Snippet 2
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Re: Static Topics

Postby kenny » 07 Aug 2008, 13:48

I should also note that I have this little snippet installed on this board as a test and deomstration.
The array currently holds 1 forum id - 2 (Announcements forum) :).
So you'll see that although my reply is later than the post at the top, the topic doesn't move as the sort is based on 1st post time ;)
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Static Topics

Postby kenny » 27 Aug 2008, 16:19

Stickified so people understand why this forum is like it is :P

Edit: This forum is no longer static (as of 22/05/2009)
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Static Topics

Postby Hubble » 11 Dec 2008, 09:14

I can't find anywhere the code in order to update the Snippet 2.
I managed to change the first code in Snippet 2, but I also want to update... if you say it is a lill' more efficient.
:) Thank you! Hope you will help me :cry:
User avatar
Hubble
Registered User
Registered User
 
Posts: 1
Joined: 11 Dec 2008, 09:07

Static Topics

Postby kenny » 11 Dec 2008, 09:49

The code in the 1st post for Snippet 2, is the more efficient code.
The code in the 2nd post, was for people who had already grabbed the old stuff ;)
I'll update my posts to reflect that :)
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Static Topics

Postby ghostt » 28 Apr 2009, 13:09

hallo this is a very good snippet i use it for long time.
now i want to know if it would be possible to sort the Subforums alphabetically.

rgds
User avatar
ghostt
Registered User
Registered User
 
Posts: 3
Joined: 28 Apr 2009, 13:04

Static Topics

Postby kenny » 29 Apr 2009, 18:14

It is with this MOD :)
Last edited by kenny on 30 Apr 2009, 09:51, edited 1 time in total.
Reason: Fixed URL
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Static Topics

Postby ghostt » 29 Apr 2009, 22:24

thank you but i need this for subforums. if i create some new subforums in an eypacialy forum they have to be in a row alphabeticaly from a-z

maybe you know a Code Snippets for it :)
User avatar
ghostt
Registered User
Registered User
 
Posts: 3
Joined: 28 Apr 2009, 13:04

Static Topics

Postby kenny » 30 Apr 2009, 10:02

Ah, I read forums as topics sorry. I don't know of any Snippets or MODs to do this I'm afraid. I'm thinking that it may be slightly hard to accomplish, just going by the way that forums are displayed. You can re-arrange them manually in the ACP - might be worth biting the bullet now and sorting them, then if you add a forum later on you only have to move that one :)
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Next



Return to Code Snippets

Who is online

Google [Bot], MSN [Bot], Yahoo [Bot]


cron