*

chris

  • **
  • 29 posts
comments order -> last comment in first position
« on: January 14, 2021, 08:56:52 AM »
don't know exactly the name of the field in the database where comments are stored, but a "order by pub_date desc" should be far better than to go on the X page to see your last message.

I'm trying to change this at this moment for my site. Any help on thos point will be much apreciated

*

MB Themes

Re: comments order -> last comment in first position
« Reply #1 on: January 14, 2021, 12:42:08 PM »
@chris
Take a look into oc-includes/osclass/model/ItemComment.php
Function findByItemID probably allows you to add sorting here.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

chris

  • **
  • 29 posts
Re: comments order -> last comment in first position
« Reply #2 on: January 14, 2021, 05:20:05 PM »
thank you. It works like a charm now. For those who are interested (everyone in fact), i have add this at this right place :

    if( $commentsPerPage == null ) { $commentsPerPage = osc_comments_per_page(); }

    $this->dao->select();
    $this->dao->from($this->getTableName());
    $conditions = array('fk_i_item_id'  => $id,
              'b_active'    => 1,
              'b_enabled'   => 1);
    $this->dao->where($conditions);
      $this->dao->orderBy( 'pk_i_id' , 'DESC' );

PS : MB theme -> you can use this code for free but feel free to make me a 80% rebate or more on my next plugin. Otherwise you can give my name to the next 4.2.4 version  , or put a slide show with some pictures of me on your frontpage, ...
« Last Edit: January 14, 2021, 07:53:59 PM by chris »

*

chris

  • **
  • 29 posts
Re: comments order -> last comment in first position
« Reply #3 on: January 14, 2021, 07:51:07 PM »
To go further in the improvement of the comments, i've add this in the item.php ot the sigma theme to show the day of the publication of the comment (for me it's enough, but we can add the hour, ... )

            <?php
$datepubli = osc_comment_pub_date();
$datepubli2 = strftime(" %d %m %G", strtotime($datepubli));
?>


              <h3><strong><?php echo osc_comment_title(); ?></strong> <em>(<?php _e("by", 'sigma'); ?> <?php echo osc_comment_author_name(); ?> le <?php echo "$datepubli2"; ?>)</em></h3>

maybe another better way to do this ?