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


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 3 years, 9 months ago by  Tony. Reason: Fixed forum crazy code formatting

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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Tony 3 years, 9 months ago ago

Topic Tags

Tagged: 

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!