Support Forum
I'm curious if there's a way to sort the order of the topics in only one of our forums by the date they were posted instead of by which topic has the most recent post.
Looking through the WIKI here, it seems this was an option at one point or another:
http://wiki.simple-press.com/a.....-settings/
Our forum is used for classified ads so we only want new listings to appear as the most recent to our members.
Thanks!
yes... on the forum view, use the forum tools and select reverse sort this forum...
Visit Cruise Talk Central and Mr Papa's World
I suspect what Steve is suggesting wont give you quite what you want either. That option will reverse sort and keep the oldest topics at the top but it will still sort the newest according to which ones have received a post - just at the end.
If, by the question, you literally meant in the order that the topic (i.e., first post) was created then this can be done but it needs a small piece of code to run against the database query using one of our filter hooks. In this case the 'sph_forumview_query' filter. From this you can adjust the sort order.
YELLOW
SWORDFISH
|
Yellow Swordfish said
If, by the question, you literally meant in the order that the topic (i.e., first post) was created then this can be done but it needs a small piece of code to run against the database query using one of our filter hooks. In this case the 'sph_forumview_query' filter. From this you can adjust the sort order.
Yes, that's exactly what I mean. I've never used your filter hooks but am somewhat familiar with Wordpress hooks in general as well as PHP. Is there a "how-to guide" somewhere explaining how to use your filters and what code would I need to use to be able to achieve this topic order?
Thanks!
our filters work identically to wp filters... use the filter Andy referenced and replace the sort order...
this is the filter usage:
$spdb = apply_filters('sph_forumview_query', $spdb, $this);
take a look at the $spdb object that is passed... you will want to update $spdb->orderby element to what you want... for reference, $this will contain the forum view class object...
Visit Cruise Talk Central and Mr Papa's World
This one is actually pretty simple... We would suggest that you put the code in the forum theme template file spFunctions.php... Try this:
add_filter( 'sph_forumview_query', 'my_filter', 1, 2 ); function my_filter( $db, $forum ) { if ( $forum->forumId == XX ) { $db->orderby = 'topic_id ASC'; } return $db; }
Basically copy and paste this exactly as it is. Of course you can change the function name if desired!
Firstly replace the XX with the ID of the forum you wish to change the sort order of. You can find that in the admin Manage Forums listing.
Now the normal, default order by instruction is:
ORDER BY topic_pinned DESC, spf_sftopics.post_id DESC
To change this to order by when the topic was created starting with the oldest then use the code given. If you want the newest first then change to
topic_id DESC
If you DO have some pinned topics and wish those to stay on top use:
ORDER BY topic_pinned DESC, topic_id ASC
And hopefully that will do the trick. Oh - one more thong...
As always we recommend that you create your own SP theme so that any customisation is not lost during a future update. (http://codex.simple-press.com/.....g-a-theme/)
YELLOW
SWORDFISH
|
1 Guest(s)