Skip to main content
Topic: Importing (Read 2006 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Importing

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

Re: Importing

Reply #1

@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.
Bugs creator.
Features destroyer.
Template killer.

Re: Importing

Reply #2

I'm searching the code but not having any luck in finding the right routine that affects it.

Re: Importing

Reply #3

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.

Re: Importing

Reply #4

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.
Bugs creator.
Features destroyer.
Template killer.

Re: Importing

Reply #5

That did it but changing last_post so its ordered by last comment

Thanks

Re: Importing

Reply #6

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

Re: Importing

Reply #7

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. :)
Bugs creator.
Features destroyer.
Template killer.

Re: Importing

Reply #8

Cheers will check it later

Re: Importing

Reply #9

That seems to be working fine, thanks emanuele

Re: Importing

Reply #10

yw. :)
Bugs creator.
Features destroyer.
Template killer.

Re: Importing

Reply #11

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?

Re: Importing

Reply #12

Nope, where is it?
Bugs creator.
Features destroyer.
Template killer.