Support

Home Forums Event Espresso Premium Table View Add-on | Sort by Date Descending appears broken

Table View Add-on | Sort by Date Descending appears broken

Posted: September 10, 2015 at 6:19 pm

Viewing 1 reply thread


NHM

September 10, 2015 at 6:19 pm

I am using the Table View add-on to display an itinerary on my site. I am using the “improved” version of the template uploaded to the uploads/espresso folder. I have reordered the columns and I have also changed the display format of a few things as well (with a lot of trial and error).

I just noticed that when I switch the sorting of the Date column to descending it orders the column alphabetically by the name of the month. I am wondering if I have totally messed up something by moving the columns and changing the format, or if there is something else wrong.

You can view the sort here: http://nothinghidden.com/itinerary

WordPress 4.3
EE4: 4.8.8.p
Table View: 1.3.3.p


Tony

  • Support Staff

September 11, 2015 at 5:07 am

Hi there,

The problems is your date columns are missing the data-value attribute – http://take.ms/ZI9mC

So the only thing the table can sort by is the values within that column (which it does alphabetically)

For the start date column you should have something like this:

<td class="start_date event-<?php echo $post->ID; ?>" 
  	data-value="<?php echo strtotime( $startdat ); ?>">
		<?php echo date_i18n( 'F j', strtotime( $startdat ) ) // <-- start date
		  . ' - ' // <-- separator
		  . date_i18n( 'F j, Y', strtotime( $enddat )); // <-- end date 
		?>
</td>

The important part for the sorting is this part –

data-value="<?php echo strtotime( $startdat ); ?>"

Because that adds the data-value attribute as a timestamp that can be sorted.

You can change the date_i18n() calls for different formats but you still need that other code in place for the sorting.

  • This reply was modified 9 years, 2 months ago by Tony. Reason: Fixed forum crazy code formatting
Viewing 1 reply thread

The support post ‘Table View Add-on | Sort by Date Descending appears broken’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso