WordPress.org

Ready to get started?Download WordPress

Forums

TablePress
[resolved] Syntax for multiple row filter in url (10 posts)

  1. joneskc_uk
    Member
    Posted 1 year ago #

    Hi,
    I've looked through various old posts but am still not clear on what the correct syntax to express a multiple filter from a url is or whether its possible.

    I have various tablepress extension installed and the shortcode 'and' filters work fine eg. "word1||word2".

    However what is the equivalent in a url? I've tried http://www.example.com/page1/?table_filter=word1||word2, ...word1+word2, ....word1 and word2, ....word1+and+word2 but no rows are returned.

    Appreciate any comments.

    Best Rgds
    Kevin

    http://wordpress.org/extend/plugins/tablepress/

  2. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Kevin,

    thanks for your question.

    The row filter with the URL parameter works in the same way and syntax as the regular Row Filter Extension. Thus, the parameters are

    http://www.example.com/page1/?table_filter=word1||word2

    and

    http://www.example.com/page1/?table_filter=word1&&word2

    However, it might be necessary to URL-encode the value, to

    http://www.example.com/page1/?table_filter=word1%26%26word2

    Additionally, the Filtering Extension with the GET parameter needs to be modified, as it does only allow letters and numbers by default, due to this line in its code:

    $filter_term = preg_replace( '#[^a-z0-9]#i', '', $filter_term ); // only allow characters a-z, A-Z, and 0-9 in filter term

    You might want to extend that to

    $filter_term = preg_replace( '#[^a-z0-9|&]#i', '', $filter_term );

    Regards,
    Tobias

  3. joneskc_uk
    Member
    Posted 1 year ago #

    Tobias,
    Marvelleous, the change to the extension was needed and the | characters needed to be encoded, but now works for filtering using two words for the 'AND' logic.

    Many thanks for the prompt feedback, very elegant plugin.

    Rgds
    Kevin

  4. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    very nice! Great to hear that this helped!
    Thanks for the confirmation!

    Best wishes,
    Tobias

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

  5. joneskc_uk
    Member
    Posted 1 year ago #

    Tobias,
    Just a short follow up question to your earlier point about encoding filter parameters. I've seen some inconsistencies in the way that the '-' character is used in filtering. I was using the text ICP-OES to filter a table, but this did not return a result. ICP OES encoded as ICP%20OES worked.
    I presume this a function of your filter term statement in the extension? Is there way of searching for text with the '-' character in it?

    Rgds
    Kevin

  6. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Kevin,

    this is probably also related to the escaping of the search term in the URL. Please try again after extending the line from above to

    $filter_term = preg_replace( '#[^a-z0-9|&- ]#i', '', $filter_term );

    Regards,
    Tobias

  7. joneskc_uk
    Member
    Posted 1 year ago #

    Tobias,
    I substituted this line but got the following error

    Warning: preg_replace() [function.preg-replace]: Compilation failed: range out of order in character class at offset 11 in /homepages/29/d374934069/htdocs/labpulsar/wordpress/wp-content/plugins/tablepress-shortcode-filter-get-parameter/tablepress-shortcode-filter-get-parameter.php on line 18

    Does this make sense?

    Rgds
    Kevin

  8. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Kevin,

    ah, it might be necessary to escape the Regular Expression:

    $filter_term = preg_replace( '#[^a-z0-9|&\- ]#i', '', $filter_term );

    Sorry that I missed that...

    Regards,
    Tobias

  9. joneskc_uk
    Member
    Posted 1 year ago #

    Tobias,
    Great works now. Many thanks

    Rgds
    Kevin

  10. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    Great! Sorry again for the extra work.

    Best wishes,
    Tobias

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic