• Hello! I would first like to thank TobiasBg for your amazing plugin AND support. It has saved me so much time on a project I’m working on for a client. You’re killing it!

    My question revolves around auto-filtering via current date. I have one table with a historical list of data sorted by descending dates which appear within the rows, going as far back as 2010. I need to show the same table across two different pages, one page would only show the most recent 6 mo. of data, and the other page would hide the most recent 6 mo. of data (this is going to be an archive page). Eventually, this section will be managed by non-developers so I need this to be done automatically. Is this possible? Additional wrench: this is a regulated project and I cannot publicly share a dev link. But, I can share that I’m already using this in the custom commands box:

    "columnDefs": [ { "orderable": false, "targets": [ 0,6,7,8] } ]

    Here’s a little info on my skill set if it helps: I am a designer by trade and developer by necessity; expert in CSS/HTML, ok with jquery. Meh with PHP.

    THANK YOU!

    https://ww.wp.xz.cn/plugins/tablepress/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Unfortunately, I can’t really think of a directly usable solution here 🙁
    Your best bet probably is the approach that is described in https://ww.wp.xz.cn/support/topic/show-only-future-dates?replies=14 with that TablePress Row Filter by Date Extension. It might need modifications due to that 6 months timeframe.

    Regards,
    Tobias

    Thread Starter Jen via CDS Support

    (@cds2016)

    Yes—I came across that thread in my search but moved on as it didn’t seem to mention any way of setting any sort of a date range.

    I will take your advice and look into modifying the extension you shared. We’ve already got 5 of your extensions installed so thanks again for all you’ve done with this plugin—I know this date situation is probably a crazy, one-off need.

    I can probably figure out how to setup a ‘show only dates within a 6-mo range’ environment eventually, but do you have any guidance on how to make this work for both tables? Where one shows the most recent 6 mo. of data, and the other page would hide that data? It’s been years since I’ve gotten down with good ol’ PHP. Of course, I plan to share any solution I end up with here in the forum, just in case anyone in the future has a similar need.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    the “trick” here would be to modify the _filter_date_is_past() and _filter_date_is_future()` methods as necessary. They are comparing the dates in the table with “today”, so you would have to add an offset of 6 months to that comparision.

    Regards,
    Tobias

    Thread Starter Jen via CDS Support

    (@cds2016)

    Thanks! It looks like I got it to work by modifying the code as you advised:

    line 63:

    return ( $date_timestamp < strtotime( 'today' ) && $date_timestamp < strtotime( '- 6 months' ) );

    line 95:

    return ( $date_timestamp < strtotime( 'today' ) && $date_timestamp > strtotime( '- 6 months' ) );

    Please let me know if you think anything about the mods are a bit “hacky” since I’m quite rusty at PHP, but so far it looks functional for my client’s needs.

    Thank you for your help with this, and for a great plugin!

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    yes, that’s basically what I had in mind 🙂
    Good to hear that you were able to implement this so quickly!

    In the first line, you could probably even remove the first condition, as it’s redundant.

    Best wishes,
    Tobias

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

    Thread Starter Jen via CDS Support

    (@cds2016)

    Well, I was only able to get it up and running so quickly due to your awesome support! I do plan on tossing a decent donation your way as I foresee using your plugin quite a lot in the future—thanks for your awesome contribution and time dedication to the WP community.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thank you so much for your donation, I really appreciate it!
    All the best for your project!

    Best wishes,
    Tobias

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

The topic ‘Auto-hide Rows based on Date’ is closed to new replies.