All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Display Next Upcoming Date of a School Session

TR Douglas 19 Jun 2012 02:46 question, complete

Newbie still figuring out how best to use LV. Can I use it to display the next upcoming date for a school that has 7 sessions each year?

For example, if I use the current time, I'd want to display the very first date that appears in the future.

The client needs to easily update the dates... so would I create a group for "School Sessions" and then create a separate variable for each date? If so, can I compare all the variables in a group to the current time?

Thanks!

Replies

  1. Low 19 Jun 2012 09:12

    If you're going to create a variable per date, you'd have to create a lot of conditionals to do the checking. Instead, I'd probably use Pixel & Tonic's Matrix as a single variable, and store each date in a row.

    Then you could use a tag like this to get the correct date, using Matrix' handy parameters:

    {exp:low_variables:pair 
    var="my_matrix_var"
    search:my_date_col=">{current_time}"
    limit="1"
    orderby="my_date_col"
    sort="asc"}
    {my_date_col format="%d-%m-%Y"}
    {/exp:low_variables:pair}


    ...untested, but something like that could work.

  2. TR Douglas 20 Jun 2012 20:39

    And indeed that does work... been testing a range of other vars today and starting to pick it up... many thanks!

  3. TR Douglas 9 Sep 2012 15:57

    Follow up on this question now: Can we use the output of a plugin inside the low_variables:pair?

    We made a very basic plug-in to subtract 4 days from the current time.

    class Shifter 
    {
    public function buffer()
    {
    $today = date("Y-m-d");
    $buffer = strtotime($today ."-4 days");
    return $buffer;
    }
    }
    But we don't get the correct result when we replaced the current_time tag with the plug-in tag in the low_variables:pair.
    search:session_date=">{exp:shifter:buffer}"   
    Is this feasible? Thanks much!

  4. Low 10 Sep 2012 05:50

    As a rule, using a plugin tag as input for another tag's parameter will not work, due to parse order. You'd have to change the plugin to work as a tag pair and wrap it around the LV tag.

  5. TR Douglas 10 Sep 2012 12:11

    Ahh, OK, we'll work on that... thanks!