ElkArte Community

Project Support => Support => Topic started by: fritzelly on August 25, 2018, 01:05:35 pm

Title: Importing
Post by: fritzelly on August 25, 2018, 01:05:35 pm
I'm importing a whole load of threads from another forum
Issue is they all show at the top of the threads i.e. newer threads started with software are on the last page
I've looked thru the tables but cannot see where they are getting a newer timestamp showing them first
Title: Re: Importing
Post by: emanuele on August 25, 2018, 02:33:23 pm
@fritzelly there are several discussions about this: the sorting of topics and posts in ElkArte is done using the id of the topic/post, and not with the timestamp. That means that when importing if the import just creates new topics on top of the existing everything will be kind of messed up.

I guess, at that point, your only solution is change the sorting code and make it sort by timestamp instead of id.
I don't have an answer ready, I have to dig a moment in the code.
Title: Re: Importing
Post by: fritzelly on August 25, 2018, 02:39:12 pm
I'm searching the code but not having any luck in finding the right routine that affects it.
Title: Re: Importing
Post by: fritzelly on August 25, 2018, 04:04:05 pm
So narrowed it down to this function in MessageIndex.subs.php I think
function messageIndexSort()

Now just need to find the code that is calling it as the poster_time doesn't seem to be part of the columns called.
Title: Re: Importing
Post by: emanuele on August 25, 2018, 06:59:59 pm
You can try changing:
Code: [Select]
'first_post' => 't.id_topic',
to:
Code: [Select]
'first_post' => 'mf.poster_time',
I'm not entirely sure, but worth a try.
Title: Re: Importing
Post by: fritzelly on August 26, 2018, 03:09:02 pm
That did it but changing last_post so its ordered by last comment

Thanks
Title: Re: Importing
Post by: fritzelly on August 26, 2018, 05:18:12 pm
Actually doesn't work - first page and last page ok but any pages in between give this error

Unknown column 'mf.poster_time' in 'order clause
Title: Re: Importing
Post by: emanuele on August 26, 2018, 05:39:22 pm
Okay, yes indeed.

The replacement should be:
Code: [Select]
		'first_post' => 't.id_topic',
'last_post' => 't.id_last_msg'
to:
Code: [Select]
'first_post' => 'mf.poster_time',
'last_post' => 'ml.poster_time'
And this redefines the sorting order for last message (from message id to last post time) and first message (from topic id to first post time).

And, same file:
Code: [Select]
FROM {db_prefix}topics AS t' . ($sort_by === 'last_poster' ? '
to:
Code: [Select]
FROM {db_prefix}topics AS t' . (in_array($sort_by, array('last_poster', 'last_post') ? '
This should join the messages table (last => ml) for both last_poster and last_post (as modified above).
And:
Code: [Select]
in_array($sort_by, array('starter', 'subject'))
to:
Code: [Select]
in_array($sort_by, array('starter', 'subject', 'first_post'))
to join the message table (first => mf) for all the cases, including the above modified first_post.

Again, not tested (I'm working on other stuff and I don't have handy a good place to test)... sorry. :)
Title: Re: Importing
Post by: fritzelly on August 27, 2018, 04:54:39 am
Cheers will check it later
Title: Re: Importing
Post by: fritzelly on August 28, 2018, 02:55:14 pm
That seems to be working fine, thanks emanuele
Title: Re: Importing
Post by: emanuele on August 28, 2018, 04:24:30 pm
yw. :)
Title: Re: Importing
Post by: fritzelly on August 28, 2018, 05:26:48 pm
Don't know if you saw the question about the friendly url stuff you were doing a good while ago.
If it's dead in the water I will have a look at it this weekend, starting to get a grip on the code now and got plenty of experience coding friendly urls - not sure how I write it as an addon  but if I can point out the stuff to add maybe you can do the compiling bit?
Title: Re: Importing
Post by: emanuele on August 29, 2018, 05:39:46 am
Nope, where is it?