Okay
  Public Ticket #2121893
Event List
Closed

Comments

  • Doğuş Ozan CİHAN started the conversation

    I'm trying to list events in the drop-down menu below the months. How can I do it ? 

    It should be like the second image.

  • Doğuş Ozan CİHAN replied

    Pls Reply

  •  94
    Valentin replied

    Good morning,

    We don't have such design. In our plugin the events will expand when you click on the month if you are using month or week view.

    Stachethemes Support
    My Time Zone is GMT+3


    Envato Profile | Facebook | Twitter | Newsletter | Rate & Review

  • Doğuş Ozan CİHAN replied

    I don't need it in design. 

    Help me list all the events in the months on the php side.

    Thanks for your answer


  •  94
    Valentin replied

    I'm sorry, but we don't make such customization requests. You can hire an developer from Envato Studio that do customizations on WordPress items here: https://studio.envato.com/explore/wordpress-customization?&utm_campaign=internal+navigation&utm_content=footernav&utm_medium=codecanyon&utm_source=marketplaces&sort=relevance&page=1

    Stachethemes Support
    My Time Zone is GMT+3


    Envato Profile | Facebook | Twitter | Newsletter | Rate & Review

  • Doğuş Ozan CİHAN replied

    I've listed all the events, like this.

    fillEventList: function () {
        var from = helper.getDateFromData('2019-1-01');    var to = helper.getDateFromData('2025-1-01');
        var events = calData.getEvents(from, to);
        $(events).each(function () {        var eventItem = this;        var eventItemDate = helper.beautifyTimespan(eventItem.start_date, parseInt(eventItem.hide_end, 10) === 1 ? false : eventItem.end_date, eventItem.all_day);
            $(glob.template.eventList).html(function (index, html) {            return html                
                                                                                             .replace('stec_replace_event_background', 'style="background:' + eventItem.color + '"')               
                                                                                             .replace('stec_replace_summary', eventItem.title)                
                                                                                             .replace('stec_replace_date', eventItemDate);        }).appendTo($('.stec-event-list-template'));
        });

    But I can't fetch the month in which the events belong.

    I don't think it's compelling enough to require support.

    Please help me =(



  •  877
    Zhivko replied

    Both codes are written to work from your theme functions.php file.

    Javascript implementation:

    add_action('wp_footer', function() {
        ?>
        <script type="text/javascript">
            (function ($) {             if (typeof $.stecExtend !== 'function') {
                    return;
                }             var hook = 'onAddToEventsPool'; // Trigger extensions after the events have been added to the calendar             $.stecExtend(function (m) {
                    var calData = m.calData;                 var startDate = new Date(2019, 7, 1); // Range start. Note months in js are between 0-11;
                    var endDate = new Date(2019, 7, 31);  // Range end. Note months in js are between 0-11;
                    var includeUnapproved = false; // Include unapproved events to the list. True / False
                    var events = calData.getEvents(startDate, endDate, includeUnapproved); // Retrieves events, takes rrule into account                 // If has events
                    if (events && events.length > 0) {
                        // Loop each event
                        $.each(events, function () {
                            var event = this;                         var eventTitle = event.title;
                            // ...
                            // ...
                            // ...                         console.log(event); // Display each event properties in the browser console 
                        });
                    }             }, hook);         })(jQuery);
        </script>
        <?php
    });

    PHP implementation:

    add_action('init', function() {
        
        // Set date ranges
        $start_date = '2019-08-01'; // Range start. Must be database date YYYY-MM-DD;
        $end_date   = '2019-08-31'; // Range end. Must be database date YYYY-MM-DD;
        $params               = array();
        $params['meta_query'] = array(
            'key'     => 'start_date',
            'value'   => array($start_date, $end_date), // Note does not take into account the repeater since the rrule is generated by js
            'compare' => 'BETWEEN',
            'type'    => 'DATE'
        );
        
        // Query the events
        $events = \Stachethemes\Stec\Events::get_events($params);     if ($events && is_array($events)) {         foreach ($events as $event) {
                if (false === ($event instanceof \Stachethemes\Stec\Event_Post)) {
                    continue;
                }             $event_title = $event->get_title();
                // ...
                // ...
                // ...
            }         // Prints event object methods
            echo '<pre>';
            print_r(get_class_methods($event));
            echo '</pre>';         unset($event);
        }
    });

    Stachethemes Developer

  • Doğuş Ozan CİHAN replied

    thx for reply =)

    i have a little problem.

    Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in \wp-includes\wp-db.php on line 1172Call Stack

  •  877
    Zhivko replied

    Ensure $start_date and  $end_date are type string and not arrays. 

        $start_date = '2019-08-01'; // Range start. Must be database date YYYY-MM-DD;
        $end_date   = '2019-08-31'; // Range end. Must be database date YYYY-MM-DD;

    Stachethemes Developer

  • Doğuş Ozan CİHAN replied

    i'm sure but doesn't work =(

  •  877
    Zhivko replied

    Could you send me your code?


    Stachethemes Developer

  • Doğuş Ozan CİHAN replied

    <?php
    namespace Stachethemes\Stec; ?>
    <div id="<?php echo $calendar; ?>" class="stec">
        <?php if ($calendar->get_shortcode_option('stec_menu__general', 'show_top') === '1') : ?>
            <?php include("inc.top.php"); ?>
        <?php endif; ?>
        <div class="stec-layout">        <?php include("layout.agenda.inc.php"); ?>        <?php include("layout.month.inc.php"); ?>        <?php include("layout.week.inc.php"); ?>        <?php include("layout.day.inc.php"); ?>        <?php include("layout.grid.inc.php"); ?>        <?php include("layout.boxgrid.inc.php"); ?>        <?php include("layout.map.inc.php"); ?>    </div>
        <div class="stec-tooltip-template">        <?php include("layout.tooltip.inc.php"); ?>    </div>
        <div class="stec-event-template">        <?php include("layout.event.inc.php"); ?>    </div>
        <div class="stec-event-create-form-template">        <?php        if ($calendar->get_shortcode_option('stec_menu__general_event_submit', 'show_create_event_form') === '1') {            include("forms/inc.create.form.php");        }        ?>    </div>
        <div class="stec-event-awaiting-approval-template">        <?php include("layout.event.aaproval.inc.php"); ?>    </div>
        <div class="stec-grid-event-template">        <?php include("layout.grid.event.inc.php"); ?>    </div>
        <div class="stec-boxgrid-event-template">        <?php include("layout.boxgrid.event.inc.php"); ?>    </div>
        <div class="stec-event-inner-template">        <?php include("layout.event.inner.inc.php"); ?>    </div>
        <div class="stec-preloader-template">        <div class="stec-preloader"></div>    </div>
        <?php include(__DIR__ . "/popup/share.php"); ?>
    </div>
    <div class="deneme">    <?php
        // Set date ranges    
    $start_date = '2019-08-01'; // Range start. Must be database date YYYY-MM-DD;    
    $end_date = '2019-12-31'; // Range end. Must be database date YYYY-MM-DD;    
    $params = array();   
     $params['meta_query'] = array(    
    'key' => 'start_date',    
    'value' => array($start_date, $end_date), // Note does not take into account the repeater since the rrule is generated by js    
    'compare' => 'BETWEEN',    
    'type' => 'DATE'    );
        // Query the events    
    $events = \Stachethemes\Stec\Events::get_events($params);    
    if ($events && is_array($events)) {   
     foreach ($events as $event) {    
    if (false === ($event instanceof \Stachethemes\Stec\Event_Post))
     {    continue;    }   
     $event_title = $event->get_title();    
    // ...    
    // ...   
     // ...    }   
     // Prints event object methods    
    echo '<pre>';       
     print_r(get_class_methods($event));       
     echo '</pre>';    unset($event);    }?>
    </div>
    <script type="text/javascript">    (function ($) {        if (typeof $.stecExtend !== 'function') {            return;        }        var hook = 'onAddToEventsPool'; // Trigger extensions after the events have been added to the calendar        $.stecExtend(function (m) {            var calData = m.calData;            var startDate = new Date(2019, 7, 1); // Range start. Note months in js are between 0-11;            var endDate = new Date(2019, 7, 31);  // Range end. Note months in js are between 0-11;            var includeUnapproved = false; // Include unapproved events to the list. True / False            var events = calData.getEvents(startDate, endDate, includeUnapproved); // Retrieves events, takes rrule into account            // If has events            console.log(calData);            console.log(startDate);            console.log(endDate);            console.log(includeUnapproved);            console.log(events);            console.log(event);
                if (events && events.length > 0) {                // Loop each event                $.each(events, function () {                    var event = this;                    var eventTitle = event.title;                    // ...                    // ...                    // ...                    console.log(event); // Display each event properties in the browser console
                    });            }        }, hook);    })(jQuery);
    </script>
    
  •  877
    Zhivko replied

    Remove this code and place this one in theme functions.php.

    add_action('wp_footer', function() {
        ?>
        <script type="text/javascript">
            (function ($) {
                if (typeof $.stecExtend !== 'function') {
                    return;
                }
                $.stecExtend(function (m) {
                    var moment = window.moment,
                            calData = m.calData,
                            startRange,
                            endRange,
                            includeUnapproved = false,
                            currentMonth = 0,
                            maxMonths = 11,
                            monthLabel,
                            events,
                            html = [],
                            appendContainer = m.$instance; // end of calendar container
                    moment.locale('en');
                    html.push('<div>');
                    while (currentMonth <= maxMonths) {
                        startRange = moment().month(currentMonth).startOf('month').toDate();
                        endRange = moment().month(currentMonth).endOf('month').toDate();
                        events = calData.getEvents(startRange, endRange, includeUnapproved);
                        monthLabel = m.helper.capitalizeFirstLetter(m.glob.options.monthLabels[currentMonth]);
                        html.push('<p>' + monthLabel + '</p>');
                        html.push('<ul>');
                        if (events && events.length > 0) {
                            // Loop each event
                            $.each(events, function () {
                                var event = this;
                                var eventTitle = event.title;
                                var date = m.helper.beautifyTimespan(event.start_date, parseInt(event.hide_end, 10) === 1 ? false : event.end_date, event.all_day);
                                html.push('<li>');
                                html.push('<p>' + eventTitle + '</p>');
                                html.push('<p>' + date + '</p>');
                                html.push('</li>');
                            });
                        }
                        html.push('</ul>');
                        currentMonth++;
                    }
                    html.push('</div>');
                    html = html.join('');
                    $(html).appendTo(appendContainer);
                }, 'onAddToEventsPool');
            })(jQuery);
        </script>
        <?php
    });
    

    Stachethemes Developer

  • Doğuş Ozan CİHAN replied

    You are the best 

    It is worked

    very thx =)