Support » Plugin: Google Calendar List View » Add element count and output for no elements

  • Resolved Bannix

    (@bannix)


    Hi,
    for this nice plugin I want to propose an additional feature which I implemented for myself on my website.

    I’m filtering the events shown based on a keyword I may set in the description of an event. If the keyword is there, I want to show the event in the list view, if it’s not, then i don’t want to show it, which I do by setting the output to an empty string via the lvgc_each_output_data hook. However, with this method the maxResults parameter doesn’t work as intended, because it still counts events whose output is an empty string. I introduced a new parameter that counts the number of events whose output is not an empty string, and I pass that to the hook. I also added a custom output message that is displayed when there are no non-empty events.

    This additional feature, which doesn’t break or modifiy any other functionality of the plugin, is done by only a very small amount of additional code in list-view-google-calendar.php:

    after line 189 add:
    $element_count = 0;

    after line 268 add:
    'element_count' => $element_count,

    replace line 278 with:
    $tmp = wp_kses_post($out_t['data']);
    $out .= $tmp;
    if (!empty($tmp)):
    ++$element_count;
    endif;

    replace line 288 with:`
    if (empty($out)):
    $out = "There are no events.";
    endif;

    Do you think it’s possible to include this into the plugin?

    Best
    Bannix

    • This topic was modified 1 year, 10 months ago by Bannix.
    • This topic was modified 1 year, 10 months ago by Bannix.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author kimipooh

    (@kimipooh)

    Thank you for using my plugin.

    Your request is now supported in version 6.0.
    In addition, I added the hash_tag (#display). By setting up hash_tag (#display none or #display off) in an event description, so the event isn’t displayed.

    Thread Starter Bannix

    (@bannix)

    Very nice, thank you!!
    I actually use a translated version of “There are no events” message. Maybe it would be a good idea to be able to provide a custom message in the plugin settings page for this?

    Plugin Author kimipooh

    (@kimipooh)

    Your idea is good!

    I added this feature as of version 6.1.
    You input the message to the “No Event Message” item in the general setting of the plugin setting or the “no_event_message” shortcode option.
    If the value is empty, “There are no events.” is set. Else if the value is “none”, the message is hidden. If the “no_event_message” shortcode option is set, the message is overwritten by the shortcode message

    Thread Starter Bannix

    (@bannix)

    Perfect!
    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add element count and output for no elements’ is closed to new replies.