Events Made Easy Forums Bug fixed or feature request implemented Add Month Headers to Events List

  • This topic has 3 replies, 3 voices, and was last updated 13 years ago by Anonymous.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #42078
    Anonymous
    Inactive

    I absolutely had to have headers diving up my month in the events list, so I added a new arg to the shortcode “showmonths” – when set to 1, it inserts a new

    <li class=’dbem_month’> each time the list crosses into a new month.

    Don’t suppose there’s any chance this could be rolled into the official plugin??

    The following two functions were all I modified; the codebegins on line 361 of dbem_events.php

    /* Marcus Begin Edit */
    //Added a category option to the get events list method and shortcode
    function dbem_get_events_list($limit = "10", $scope = "future", $order = "ASC", $format = '', $echo = 1, $category = '', $showmonths = 0) {
    if (strpos ( $limit, "=" )) {
    // allows the use of arguments without breaking the legacy code
    $defaults = array ('limit' => 10, 'scope' => 'future', 'order' => 'ASC', 'format' => '', 'echo' => 1 , 'category' => '', 'showmonths' => 0);

    $r = wp_parse_args ( $limit, $defaults );
    extract ( $r, EXTR_SKIP );
    $limit = $r ['limit'];
    $scope = $r ['scope'];
    $order = $r ['order'];
    $format = $r ['format'];
    $echo = $r ['echo'];
    $category = ( preg_match('/^([0-9],?)+$/', $r ['category'] ) ) ? $r ['category'] : '' ;
    $showmonths = $r ['showmonths'];
    }
    if ($scope == "")
    $scope = "future";
    if ($order != "DESC")
    $order = "ASC";
    if ($format == ''){
    $orig_format = true;
    $format = get_option ( 'dbem_event_list_item_format' );
    }
    $events = dbem_get_events ( $limit, $scope, $order, '', '', $category );
    $output = "";
    if (! empty ( $events )) {
    foreach ( $events as $event ) {
    $themonth = date("F", strtotime($event['event_start_date']));
    if ($showmonths == 1 && $themonth != $curmonth) {
    $output .= "<li class='dbem_month'>$themonth</li>";
    }
    // $localised_date = mysql2date("j M Y", $event->event_time);
    $output .= dbem_replace_placeholders ( $format, $event );
    $curmonth = date("F", strtotime($event['event_start_date']));
    }
    //Add headers and footers to output
    if( $orig_format ){
    $single_event_format_header = get_option ( 'dbem_event_list_item_format_header' );
    $single_event_format_header = ( $single_event_format_header != '' ) ? $single_event_format_header : "<ul class='dbem_events_list'>";
    $single_event_format_footer = get_option ( 'dbem_event_list_item_format_footer' );
    $single_event_format_footer = ( $single_event_format_footer != '' ) ? $single_event_format_footer : "</ul>";
    $output = $single_event_format_header . $output . $single_event_format_footer;
    }
    } else {
    $output = "<ul class='dbem-no-events'><li>" . get_option ( 'dbem_no_events_message' ) . "</li></ul>";
    }
    if ($echo)
    echo $output;
    else
    return $output;
    }

    function dbem_get_events_list_shortcode($atts) {
    extract ( shortcode_atts ( array ('limit' => 3, 'scope' => 'future', 'order' => 'ASC', 'format' => '', 'category' => '', 'showmonths' => 0 ), $atts ) );
    $result = dbem_get_events_list ( "limit=$limit&scope=$scope&order=$order&format=$format&echo=0&category=$category&showmonths=$showmonths" );
    return $result;
    }

    #44686
    Franky
    Keymaster

    added to svn 🙂

    #44687
    Anonymous
    Inactive

    Nice! Thanks a lot!!!

    #44688
    Anonymous
    Inactive

    @tirussell

    How are you using this in your application?

    I think this is along the lines of something I’m trying to do as I’ve got lots of events on a single day and looking to show a clear break between days/months, etc.

    Thanks in advance

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Bug fixed or feature request implemented’ is closed to new topics and replies.
Scroll to Top