• Resolved glorisol

    (@glorisol)


    I am using tablepress for the website of my cycling club to show the (GPS) clubrides schedule.
    See: https://tourclubduiven.nl/toerkalender/

    Every ride has the month (e.g “2020-07” for July 2020) in the first column.
    Using the row-filter extension I can simply use the ‘filter=”2020-07″‘ phrase to filter just the rides scheduled in July 2020.

    Now I want to make this filtering dynamic, based on a global variable (e.g. “$current_month” that I want to set in the page header or footer) so that when the page opens the user only sees the rows that match the value in the variable.

    Plus the user should be able to change the filter as he/she likes (using the selection boxes from the column filter extension)

    Is there any way to accomplish this?

    • This topic was modified 5 years, 6 months ago by glorisol.
    • This topic was modified 5 years, 6 months ago by glorisol.
    • This topic was modified 5 years, 6 months ago by glorisol.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    Setting this filter term from a variable is possible by using a custom Shortcode wrapper. For some inspiration on how this works, please see https://tablepress.org/extensions/shortcode-filter-get-parameter/

    The drawback of this filter mechanism is that it’s not changeable “live” on the page (with JavaScript code). You might there want to use a custom JavaScript solution that simply changes the selection from the ColumnFilterWidgets dropdown based on a variable.

    Regards,
    Tobias

    Thread Starter glorisol

    (@glorisol)

    mm, but then would it be feasible to set the initial filtering value of the ColumnFilterWidgets dropdown to “current_month”?
    Then the user dan allways change that filter value to whatever to see another selection of the data in the table.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, this would be possible, but you would need custom JavaScript code for it.

    Regards,
    Tobias

    Thread Starter glorisol

    (@glorisol)

    You would be very helpful if you could help me with a basic function that ‘sets’ the filter value for the first column/dropdown defined in ColumnFilterWidgets.

    I looked a the plugin code and this seems too complex for me to do on my own (being able to copy/adapt javascript and php code)

    • This reply was modified 5 years, 6 months ago by glorisol.
    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    unfortunately, I don’t have this code readily available. Your best chance probably is some JavaScript code, maybe using jQuery. As I’m not the developer of the JS code of the ColumnFilterWidgets, I also don’t know where this adjustment would have to be made, sorry. It would probably even be the best to make this code run after the ColumnFilterWidgets have been added to the page.

    Regards,
    Tobias

    This is amazing, thank you!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘row_filter / Filter on variable value’ is closed to new replies.