Support

Home Forums Event Espresso Premium Time Sort Order

Time Sort Order

Posted: October 9, 2012 at 5:30 pm

Viewing 4 reply threads


amansker

October 9, 2012 at 5:30 pm

I’m pulling my hair out after thoroughly reviewing the forum and trying many “fixes”. I don’t understand why it is “broke” to begin with. Please help me get events to sort by time.

Using [ESPRESSO_TABLE max_days=”60″ qty=”300″ category_identifier=”publictour”]

Customized table sorts by date, but time slots within the day are out of order. I have tried short codes, tweaking time_date.php,espresso_table.php etc. I’m not a php programmer, but using info from posts. (I have worked with code for many years and comfy with that).

The problem is Saturdays.
http://www.greenflashbrew.com/blog/?page_id=112


amansker

October 9, 2012 at 5:31 pm

Started with version 22, but upgraded to 27 today.


Jonathan Wilson

October 9, 2012 at 7:15 pm

Hello,

On line 30 of espresso_table.php, right above the $order_by variable, add this:

$days  .= " WHERE ADDDATE('".date ( 'Y-m-d' )."', INTERVAL ".$max_days." DAY) >= e.start_date AND e.start_date >= '".date( 'Y-m-d' )."' ";

Under that is the sql query, which has an if/else statement determining whether we’re looking at a category-specific list or a general list. To get what you want, it should look like this.

if ($type == 'category'){
    $sql = "SELECT e.* FROM " . EVENTS_CATEGORY_TABLE . " c ";
    $sql .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.cat_id = c.id ";
    $sql .= " JOIN " . EVENTS_DETAIL_TABLE . " e ON e.id = r.event_id ";
    $sql .= " JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id ";
    if ( $max_days != "" ) {
        $sql .= $days;
        $sql .= " AND c.category_identifier != '" . $category_identifier . "' ";
    } else {
        $sql .= " WHERE c.category_identifier != '" . $category_identifier . "' ";
    }
    $sql .= " AND e.is_active = 'Y' ";
}else{
    $sql = "SELECT e.*, ese.start_time, ese.end_time FROM " . EVENTS_DETAIL_TABLE . " e ";
    $sql .= "LEFT JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id ";
    if ( $max_days != "" ) {
        $sql .= $days;
        $sql .= " AND e.is_active = 'Y' ";
    } else {
        $sql .= " WHERE e.is_active = 'Y' ";
    }
}

We have tested this previously and it should work. Let us know if you have anymore questions.


amansker

October 11, 2012 at 5:31 pm

Thanks for that info Jonathan. I still can’t get it to work properly. I’m starting with this modified filed which works great except for the sort order of times on the same day:

SEE CODE
http://www.greenflashbrew.com/espresso_table.txt

LIVE SCREEN:
http://www.greenflashbrew.com/blog/?page_id=112

Short code: [ESPRESSO_TABLE max_days=”60″ qty=”300″ category_identifier=”publictour”]

When I add the first line of the recommended code, there is no change. AFter adding the 2nd set of code below Line 30, I get:

Parse error: syntax error, unexpected $end

I’m not a programmer but tried various entries of } (adding, removing) with varying errors.

Could you try adding your code to the espresso_table.php or give me some hints?


amansker

October 13, 2012 at 2:42 pm

Any help? My client is pushing hard now.

Viewing 4 reply threads

The support post ‘Time Sort Order’ 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