*

chris

  • **
  • 29 posts
order by dt_mod_date desc instead of pub_date_desc
« on: January 04, 2021, 11:35:33 PM »
   Hi,

I would like search to present results by mod_date_desc when there is'nt search pattern

(to give the idea my members to modify their listing ...)

I have changed this in my search.php (the one in : oc-includes/osclass/controller/ )


1 :

// hardcoded - if there isn't a search pattern, order by dt_mod_date desc
      if($p_sOrder == 'relevance') {
        $p_sOrder = 'dt_mod_date';


2 :

if(osc_count_items()>0) {
          while(osc_has_items()) {

            try {
              $itemArray = array (
                'title'     => osc_item_title() ,
                'link'    => htmlentities( osc_item_url() , ENT_COMPAT , 'UTF-8' ) ,
                'description' => osc_item_description() ,
                'country'   => osc_item_country() ,
                'region'    => osc_item_region() ,
                'city'    => osc_item_city() ,
                'city_area'   => osc_item_city_area() ,
                'category'  => osc_item_category() ,
                   'dt_mod_date' => osc_item_mod_date()
              );



but it hasn't change the behaviour of the results  : still publication date and not modification date ...

An idea ?

THX

*

chris

  • **
  • 29 posts
Re: order by dt_mod_date desc instead of pub_date_desc
« Reply #1 on: January 06, 2021, 09:38:01 AM »
up please

*

MB Themes

Re: order by dt_mod_date desc instead of pub_date_desc
« Reply #2 on: January 07, 2021, 09:02:18 AM »
@chris
You will have to go into search controller or model and change sorting from dt_pub_date into coalesce(dt_mod_date, dt_pub_date)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

chris

  • **
  • 29 posts
Re: order by dt_mod_date desc instead of pub_date_desc
« Reply #3 on: January 07, 2021, 04:13:37 PM »
Thank you for your time & answer. It has indeed changed, but on the homepage only (latest ads) :-/

*

chris

  • **
  • 29 posts
Re: order by dt_mod_date desc instead of pub_date_desc
« Reply #4 on: January 11, 2021, 08:36:51 AM »
Sorry to insist.

in oc-includes/osclass/model/Search.php

there is :

  /**
   * Return an array with columns allowed for sorting
   *
   * @return array
   */
  public static function getAllowedColumnsForSorting()
  {
    return array('i_price', 'dt_pub_date', 'dt_expiration');
  }



If i change for


  /**
   * Return an array with columns allowed for sorting
   *
   * @return array
   */
  public static function getAllowedColumnsForSorting()
  {
    return array('i_price', 'dt_mod_date', 'dt_expiration');
  }


I have noticed no change at all


In the same file, If i change :


  public function order($o_c = 'dt_pub_date', $o_d = 'DESC', $table = NULL)
  {
    if($table == '') {
      $this->order_column = $o_c;
    } else if($table != ''){
      if( $table === '%st_user' ) {
        $this->order_column = sprintf("ISNULL($table.$o_c), $table.$o_c", DB_TABLE_PREFIX, DB_TABLE_PREFIX);
      } else {
        $this->order_column = sprintf("$table.$o_c", DB_TABLE_PREFIX);
      }
    }
    $this->order_direction = $o_d;
  }


to :

  public function order($o_c = 'dt_mod_date', $o_d = 'DESC', $table = NULL)
  {
    if($table == '') {
      $this->order_column = $o_c;
    } else if($table != ''){
      if( $table === '%st_user' ) {
        $this->order_column = sprintf("ISNULL($table.$o_c), $table.$o_c", DB_TABLE_PREFIX, DB_TABLE_PREFIX);
      } else {
        $this->order_column = sprintf("$table.$o_c", DB_TABLE_PREFIX);
      }
    }
    $this->order_direction = $o_d;
  }




It changes only on latest ads on the home page


Other changes that i have tryed in oc-includes/osclass/controller/search.php

(changing dt_pub_date to dt_mod_date) has had no effect.