Support Forum
I have recently done an import of a vbulletin forum into simple:press. Everything seems to be working except that the the order of the topics seems to be incorrect. It gives the most recent topic being one that is 2 months old, and there are many others that are newer. I have figured out the reason this occurs is because in the import the post_ids are not necessarily in order of date. This is not a problem for most things except for in the sp-list-topic-class.php file the order of the topics is determined by the following code:
$spdb->orderby = SFTOPICS.'.post_id DESC';
I was wondering if there was a way to instead have the order be determined by the post_date information in the SFPOSTS table? If not is their a way to reorder the posts in order to get their ids to be sequential? Thanks.
you should be be able to hook into our filter on the query and change the orderby... beware that ordering by date may be a significant performance penalty... mysql just isnt set up to handle that efficiently... where as ordering by the ID (which is the same as the date in simple press) is quite efficient in mysql...
do you understand filters?
for the code you posted, a few lines lower is a filter on the $spdb object... you can just change the orderby element and return the object to sort how you like...
Visit Cruise Talk Central and Mr Papa's World
Thanks for your response. I tried to do that by adding SFPOSTS.post_date to the fields and have:
$spdb->orderby = SFPOSTS.' post_date DESC';
but it didn't work. It kept saying it was an invalid database query.
I agree that it would be better to have it done by id. Is there a way to redo the ids of the posts table (and subsequently the topic table) so that the ids are in the same order as the date?
can you post the code you used?
you would want something like the following in your spFunctions.php file...
add_filter('sph_topicview_query', 'my_topic_query', 2);
function my_topic_query($spdb, $obj) {
$spdb->orderby = 'post_pinned DESC, '.spdb_zone_datetime('post_date').' DESC';
return $spdb;
}
now, I have not tried this...
Visit Cruise Talk Central and Mr Papa's World
1 Guest(s)