Support Forum

Topic list order

ST Simon Trice
Simon Trice
Member

I am in the middle of a tedious process of migrating 12 years worth of posts from a Bravenet forum.  Because there is no access to the database I have to add all posts and replies by hand and set the post date and author.

I started doing this with no problems, the topics would appear in the correct forum group, in the correct order based on the amended topic date.

Since the last update ( the one prior to yesterdays) when I add a new topic it now appears at the top of the list instead of in it’s correct postion as if it is now being sorted by the real date posted instead of the amended date..

 

Any ideas on how to fix this so that the forum is listed by the published date instead.

 

Simon

15 Answers

New Answer

IK Ike
Ike
Member

Hey Simon,

Sounds like a big job.. What update are you referring to – 5.6.3? I don’t think there was anything in there to do with ordering topics / posts.

How exactly are you adding topics and posts? Are you doing this within the forum itself and then changing the post timestamp? Or are you doing it in the database?

Off the top of my head I’m pretty sure the only way things are organised is by post / topic date not ID although I could be wrong. I think I will probably need Andy or Steve to put some input in to this one..

ST Simon Trice
Simon Trice
Member

Hi Ike

 Yes, I am adding topics via the forum and changing the post date and author before posting.  Then adding the replies using the same method.

One at a time………..monotonous or what!

Not sure what the revision number was, I updated to the latest today so it would have happened when I applied the previous update.  It does seem that they are currently being ordered by topic ID at the moment rather than topic date though.

IK Ike
Ike
Member

Yes sounds very tedious. Just out of interest why can’t you access the original database? I know people have had success with gConverter (gconverters.com) but I can’t find any reference to Bravenet.

I apologise, after some digging posts are actually ordered by ID which makes sense generally speaking – The ID is created as the post is created so ID / date go hand in hand.

You can change the post ID’s in the database but you would have to be very careful as you’d have to make sure all references to the ID’s match up. Again will have to wait for Andy or Steve to offer any further advice.

ST Simon Trice
Simon Trice
Member

Hi Ike

Bravenet is a hosted solution my customer was using, along with half a dozen other services just to build a single site.  I am merging everything into a single platform.  The issue is that there is absolutely no way to export anything from Bravenet (they do not like you to leave).

Is there any way I can use sph_forumview_query in a theme filter to change the sort order.  Have been reading through the forums for clues but there is nothing in the codex about what arguments should be used for sorting by post date.

Simon

YS Yellow Swordfish
Yellow Swordfish
Member

Ike is correct that topics are – by default – sorted by the post ID. This is the same as sorting by the post date of course.

But he is also correct that there were no changes made to anything that could effect sort ordering of posts or topics – actually for many, many releases. I really do not see what the update could have done to upset anything like that.

So… if you are adding posts as they should be entered – or as they would naturally be entered – i.e., letting the post ID increment by one for each new post then things should be fine.

If what you are saying is that you want to sort your forums with the oldest topics first – which is an unusual way to do it but I know some users do – then you just need to change the sort settings in the forum admin > options > general display settings.

ST Simon Trice
Simon Trice
Member

I’d just figured that, The earlier ones were in the correct order because I had started from the earliest posts.  The problem now is that some people have added new posts which are appearing below the posts I have since been entering.

Is there any way I can force the forum to display based on the post date shown on the topic rather than by ID.

I have seen in the forum that I may be able to use sph_forumview_query as a filter in my theme functions but as the codex is incomplete I am at a loss for what variable to sort by.

https://simple-press.com/support-forum/sp5-general-topics/sorting-topics-in-one-forum-by-post-date/#p135303

 

YS Yellow Swordfish
Yellow Swordfish
Member

The post you linked to is a perfect example actually. Leave out the ‘if’ conditional of course. And change the ‘orderby’ property to ‘post_date’- use ASC or DESC as preferred.

For the record we use post_id for the sort – which in the normal run of things equates to post_date – simply because being an integer and the primary key column it is going to be faster. No other reason.

ST Simon Trice
Simon Trice
Member

Tried that and get an invalid database query error at the top of the screen.  Inspected the database table and found that the correct header was ‘topic_date DESC’.

Thanks for all the help. smile

YS Yellow Swordfish
Yellow Swordfish
Member

Well it depends what you want to achieve. Under normal circumstances when a topic receives a new post it will shuffle that topic to the top of the list. Using topic_date wont do that.

ST Simon Trice
Simon Trice
Member

Not Really.  In the topics database table there is no column entry for post_date which is why the option offered was giving an invalid query, the post_date column is in the posts database table. 

The topic_date column gives the date the topic was posted (supplied either by the actual posting date or the amended date if using that option) so using that to sort desc will give the same output as sorting by topic_id desc if the topic post date wasn’t altered by a moderator;  In which case the topic would then appear out of position in the topic list when viewed (the exact issue I was having).

Using the topic_date instead sorts the forum topics correctly, repositioning the altered date topics accordingly.

It may be a good idea to use this as the default way of sorting forum topics if you are going to allow moderators and admins permission to change the post dates.

TBH I am surprised that it hasn’t been picked up on before, but maybe no-one has had to do quite what I am having to do with it frown

MP Mr Papa
Mr Papa
Member

no, not a good idea really – from a performance perspective anyways…  sorting in mysql on a date column is much, much slower than on an integer id, which will match date order anyways… of course, moving posts between topics can perturb that… or if data changed manually…

guess I would have to better understand the use case for lots of modifications of post dates…

and our api with filter on the database query gives easy access for you to change it as you desire…

ST Simon Trice
Simon Trice
Member

Hi Papa

I am manually having to transfer over 2000 forum topics from a hosted forum which allows no access to the back end.

The issue happens when I am adding these topics and replies (in reverse order) and an existing member decides to post a new topic on the new forum.  Everything then goes out of the window as far as sorting is concerned hence my need of the filter and having to make so (oh so many) topic date edits.

I sometimes wish I had turned the guy down but a customer is a customer.

YS Yellow Swordfish
Yellow Swordfish
Member

I kind of think any amount of money would not cover this task for me 🙂 i admit it!