Support Forum

Create Post Sort Order by Forum

EK Edward Koon
Edward Koon
Member

G’mornin..

It would be useful to be able to define post sorting by forum, or if that is not possible sort by group.

I sort my posts by oldest first, but have another forum for my blog posts that would be best sorted by newest first.

I looked before posting this message, please excuse me if i am incorrect and there is a way to sort by forum.

Thanks.. wink

30 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Can you explain just where you mean you would like this sorting behaviour? You seem to be talking about ‘posts’ but in what context? If you mean the standard Topic View – i.e, all the posts in a specific topic – then sorting by ‘forum’ or ‘group’ is meaningless. So I am a little confused…

EK Edward Koon
Edward Koon
Member

I sometimes confuse myself not knowing how to say what i am thinking.

I have one Group, with 4 Forums installed so far.

All my SP forum posts are sorted by the oldest message first.

Of these 4 Forums, one is for Blog posts that are auto created when i publish a blog post. That one forum is getting fairly long. In just that one Forum would be better to sort the Posts by newest published.

 

I considered creating another Group for those blog posts copied to SP, but didn’t see a sort order there either. 

YS Yellow Swordfish
Yellow Swordfish
Member

No worries but still a little confused!

But that s probably academic. Currently SP supports options for the sorting of topic lists (Forum View) and post lists (Topic View) but – they are globally applied to all forums and topics. So the answer sounds like it is – not at the moment.

But I will open a ticekt so we can discuss whether this is something we should consider adding.

MP Mr Papa
Mr Papa
Member

we might try to get it in next release since its straight forward, but no guarantees.

DO Dosenben
Dosenben
Member

Dear Simple:press team,

i’ll just necromance this thread – i changed the topic order to alphabetical by inserting 

add_filter(‘sph_forumview_query’, ‘my_sort_function’);
function my_sort_function($sqlObj) {
$sqlObj->orderby = SFTOPICS . ‘.topic_name ASC’;
return $sqlObj;

 

into the spfunctions.php of the template. Of course, now my beloved customer has noticed (after i told him about 15 times rolleys) that this is great for the “collector” part of the forum (german stamps; they seem to have an extremely strict numbering system…), but quite disturbing for the off-topic part (people don’t seem to number their threads there :D).

At this, i’m at my wits end. Can you think of any way to implement this; short of setting up a second forum?

 

best regards and thanks for your time!

YS Yellow Swordfish
Yellow Swordfish
Member

What are you asking for here? Is it just to add the alphabetical sort to a single forum and its topics?

DO Dosenben
Dosenben
Member

Hey Andy,

 

yeah; sorry for my confusing post – that’s pretty much it. Is that possible?

YS Yellow Swordfish
Yellow Swordfish
Member

The quickest and easiest way to confine your sort change to a single forum would be:

add_filter('sph_forumview_query', 'my_sort_function');
function my_sort_function($sqlObj) {
    global $sfvars;
    if($sfvars['forumid'] == XX) {
        $sqlObj->orderby = SFTOPICS . '.topic_name ASC';
    }
    return $sqlObj;
}

Where XX is the forum ID you want to effect.

DO Dosenben
Dosenben
Member

Hey,

 

it worked so far; splendid! But – just to get on your nerves right away (again wink): Would it be possible to do the whole things by group_id? So – sorting a complete forum group by topic_name ASC? I have a feeling that it would not, but i ask in the hope of one of your magic tricks – it’s very likely you know something i don’t. smile

YS Yellow Swordfish
Yellow Swordfish
Member

We don’t actually expose the group_id and have never been asked for it but it seems to me that it somewhat remiss not to do so and we can do basically free of charge.

So two choices.. you can either build a compound IF statement to cover all of the forum IDs in the target group – or – I can give you a small core code edit to add group_id into the $sfvars array and I can make sure that the change will make it into the next SP release.

DO Dosenben
Dosenben
Member

Hey Andy,

 

thx for your reply – the first one sounds challenging (and as if i could easily break something laugh) – so; unless it’s far simpler than i read it; i’d prefer the second choice i believe; but basically i’ll take whatever you consider the wise path.

 

thank you very much!