All-in-One Event Calendar orderby desc (reverse order)

Web programming topics
Post Reply
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

All-in-One Event Calendar orderby desc (reverse order)

Post by Neo » Sun Jul 27, 2014 11:11 pm

I spent lot of time finding a solution to show up latest events first and finally figured it out myself with a little code change in search.php under app/model

You need to find the function "get_events_relative_to" and find following code within it.

Code: Select all

            'ORDER BY i.start ' . $order_direction .
            ', post_title ' . $order_direction .
 
Replace that with following code.

Code: Select all

			'ORDER BY i.start DESC' .
Hope this will help you guys and if this was helpful don't forget to leave a comment here in ROBOT.LK ;)
User avatar
Nipuna
Moderator
Moderator
Posts: 2729
Joined: Mon Jan 04, 2010 8:02 pm
Location: Deraniyagala,SRI LANKA

Re: All-in-One Event Calendar orderby desc (reverse order)

Post by Nipuna » Mon Jul 28, 2014 9:29 pm

Wow This is Cool Neo :) :clap:
User avatar
leonelmcley
Posts: 1
Joined: Fri Aug 01, 2014 6:37 am
Location: usa

Re: All-in-One Event Calendar orderby desc (reverse order)

Post by leonelmcley » Fri Aug 01, 2014 6:48 am

This will absolutely can help thanks for sharing! ;)
User avatar
VR51
Posts: 1
Joined: Thu Aug 20, 2015 3:47 am

Re: All-in-One Event Calendar orderby desc (reverse order)

Post by VR51 » Thu Aug 20, 2015 4:01 am

Version 2.3.2 of All in One Event Calendar has been recoded. The new code to use to rearrange the date order filtering is...

Open the file /app/modal/search.php (same as before)

Find

Code: Select all

		if ( false !== $last_day ) {
			if ( 0 == $last_day ) {
				$last_day = $time;
			}
			$filter_date_clause = ' i.end ';
			if ( $page_offset < 0 ) {
				$filter_date_clause .= '<';
				$order_direction     = 'DESC';
			} else {
				$filter_date_clause .= '>';
				$order_direction     = 'ASC';
			}
			$filter_date_clause .= ' %d ';
			$args[0]             = $last_day;
			$first_record        = 0;
		}
Replace with

Code: Select all

		if ( false !== $last_day ) {
			if ( 0 == $last_day ) {
				$last_day = $time;
			}
			$filter_date_clause = ' i.end ';
			if ( $page_offset < 0 ) {
				$filter_date_clause .= '<';
				$order_direction     = 'ASC';
			} else {
				$filter_date_clause .= '>';
				$order_direction     = 'DESC';
			}
			$filter_date_clause .= ' %d ';
			$args[0]             = $last_day;
			$first_record        = 0;
		}
The difference between those two code blocks is that 'ASC' & 'DESC' have been switched around.

Thanks for the original tip, Neo. Ordinarily I'd write tips like this on my own blog but I've found the original tip here so useful I thought I'd show gratitude and post here in this forum instead. Keeping it all in one place, I guess.
Post Reply

Return to “Web programming”