Sorting of Featured Events block

Hi,

I'm trying to change the sorting of a "featured events" block on the homepage, but can't find a way. I want to reverse the sorting based on the date of the posted events. Currently it's oldest-to-newest and I want to reverse that order. Any ideas? I don't know if its relevant but below is the data from the phpadmin database for the block, I think.

a:3:{s:6:"module";s:9:"bx_events";s:6:"method";s:15:"browse_featured";s:6:"params";a:1:{i:0;s:7:"gallery";}}

  • 181
  • More
Replies (2)
    • I asked ChatGPT for a recommendation and here is it's suggestion:

      1. Add a tiny child class that forces ascending order

      Create (or upload) this file inside the Events module, e.g.

      modules/boonex/events/classes/BxEvFeaturedStartAsc.php:

      <?php
      // Featured events, sorted by event_start ASC (soonest first)
      class BxEvFeaturedStartAsc extends BxEventsSearchResultFeatured
      {
          protected function getAlterOrder ()
          {
              // Use event_start not added, and ASC so August comes before October
              return ['order' => "`bx_events_entries`.`event_start` ASC"];
          }
      }
      (If you want the reverse again later, just switch ASC↔DESC.)
      

      ### 2 Tell the homepage block to load that class

      Edit the content column of the block in sys_pages_blocks (or via Studio → Pages → your block → “Code view”) so it includes two override parameters:

      a:3:{
          s:6:"module";s:9:"bx_events";
          s:6:"method";s:15:"browse_featured";
          s:6:"params";a:3:{
              i:0;s:7:"gallery";                       // existing view mode
              s:20:"override_class_name";s:21:"BxEvFeaturedStartAsc";
              s:20:"override_class_file";s:56:"modules/boonex/events/classes/BxEvFeaturedStartAsc.php";
          }
      }
      
      

      (Leave the rest exactly as it was.)

      ### 3 Clear caches

      • Studio → Dashboard → Clear cache, or
      • delete everything inside /cache/ and /cache_public/, or
      • run php upgrade.php cleanup from the console.

      Will the above suggestion work, or will it mess up everything?


      • Hello @george1 !

        Well, the AI didn't "hit target" this time, only "straddled". You may try to do the next variant:

        In the modules/boonex/events/classes/BxEventsSearchResult.php file you need to find the following code:

        case 'featured':

              return array('order' => ' ORDER BY `bx_events_data`.`featured` DESC ');

        and change it to the:

        case 'featured':

              return array('order' => ' ORDER BY `bx_events_data`.`published` DESC, `bx_events_data`.`featured` DESC');

        Login or Join to comment.