Forums

[resolved] fullcalendar, mysql ,query (1 post)

  1. dsg257
    Member
    Posted 1 year ago #

    hi i am looking for some help
    i was helped with the following code a while back and i am greatfull for it
    i have now hit a problem

    i wish the page to show events listed from the FullCalendar which it does but now
    it is showing up old events that have past,as well as future ones.

    can anyone help with the code to only show future events or within a particular time period

    this is all the code used for the output

    function code

    // [mm-event catid=7]
    // catid is 5, 6, or 7
    function mm_event_function ($atts) {
    global $wpdb,$mm_events;
    extract(shortcode_atts(array(
    'catid' => 0,
    ), $atts));
    $op = '';
    if (!$mm_events) {
    $sql = "
    SELECT DISTINCT events.*,cats2.catid
    FROM wp_fsevents events
    JOIN wp_fsevents_cats cats1 ON (events.eventid = cats1.eventid)
    JOIN wp_fsevents_cats cats2 ON (events.eventid = cats2.eventid)
    WHERE cats1.catid = 8
    AND cats2.catid IN (5,6,7)
    ORDER BY tsfrom, tsto";
    $annual_events = $wpdb->get_results($sql);
    // Get events into arrays keyed on [catid]
    foreach ($annual_events as $event) {
    $mm_events["$event->catid"][] = $event;
    }
    }
    if ($events_in_cat = $mm_events[$catid]) {
    $catname = get_cat_name($catid);
    $pg = get_option('fse_page'); // Get the single event display page
    $url = '';
    if ($pg) $url = add_query_arg('page_id',$pg,home_url());
    $op .= "<div id='ae-cat$catid' class='ae-events'>\n";
    $op .= "<div class='ae-catname'>Meetings for $catname</div>\n";
    foreach ($events_in_cat as $annual_event) {
    $op .= "<div class='ae-event'>\n";
    $op .= "<div class='ae-subject'>";
    if ($url) $op .= "eventid,$url) . "' >";
    $op .= $annual_event->subject;
    if ($url) $op .= '
    ';
    $op .= "</div>\n";
    $op .= "<div class='ae-tsfrom'>" . date('F jS, Y',$annual_event->tsfrom) . "</div>\n";
    $op .= "<div class='ae-description'>$annual_event->description</div>\n";
    $op .= "<div class='ae-separator'></div>\n";
    $op .= "</div><!-- End ae-event -->\n";
    }
    $op .= "</div><!-- End ae-events -->\n";
    }
    return $op;
    }
    add_shortcode('mm-event','mm_event_function');

    css code

    /* ===== Styles for shortcode mm-event ==== */
    .ae-events {
    width: 60%;
    margin: auto;
    }
    .ae-catname {
    background-image: url("images/blockheader.png");
    text-align: center;
    background: #e5c348;
    font-size: 1.5em;
    color: #000000;
    margin: 20px auto;
    padding-top: 10px;
    padding-bottom: 10px;
    }
    .ae-event {
    border-bottom: 1px solid black;
    padding-bottom: 5px;
    margin-bottom: 10px;
    }
    .ae-subject { /* Similar to h2 */
    color: #000000;
    font-size: 22px;
    margin: 0.2em 0;
    }

    /* ==== End Styles for mm-event ==== */

    output page

    http://www.pgracglasgow.co.uk/?page_id=593

    code on page
    [mm-event catid=7]

    Any and all help greatfull recieved

Topic Closed

This topic has been closed to new replies.

About this Topic