• Resolved Mick37

    (@mick37)


    Hi Tobias
    Great plugin, I use it on a number of sites!

    I am looking for some functionality that I am not sure is available in Tablepress at the moment.
    I am building an ecommerce website and using Woocommerce as my shop. I have a plugin that allows me to enter a postcode to find the delivery cost of my products, based on the location of the customer. Unfortunately this facility is only available on the checkout page and i would like my customers to be able to see their delivery costs before they get that far.

    So I am using a table to show delivery costs that lists all UK postcodes and the corresponding cost. The issue with this is there are lots of postcodes and it means the customers have to find theirs in the list. Not a big issue but not the best customer experience.

    Is there a way I can just offer the facility to search the table by entering their postcode and the results appear, without having to display the entire table?
    i.e. hide the table and just show the results…?

    At the moment I have my postcodes grouped into zones and i know that i will probably need a row per postcode and that’s fine.. I just don’t want to have to display the entire table, only the results of the search.

    Any ideas?

    https://www.dev.niftymarketing.co.uk/chimney.co.uk/product/aarrow-ecoburn-plus-5kw/
    The table is in the Delivery tab.

    https://www.ads-software.com/plugins/tablepress/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    Yes, this is possible using a TablePress Extension. For details, please see the post at https://www.ads-software.com/support/topic/search-function-questions?replies=11#post-4109896

    Regards,
    Tobias

    Thread Starter Mick37

    (@mick37)

    Hi Tobias

    Thanks for the reply.
    So I have loaded the plugin extension and if I am understanding your instructions correctly I have found this code in the php –

    // Only use this functionality on these pages:
    if ( ! is_page( array( ‘page-slug-1’, ‘page-slug-1’ ) ) ) {
    return $commands;
    }

    and replaced it with this code –

    // Only use this functionality on these pages:
    if ( ! is_page( array( ‘aarrow-ecoburn-plus-5kw’, ‘aarrow-ecoburn-plus-5kw’ ) ) ) {
    return $commands;
    }

    Unfortunately it doesn’t work, i.e. there is no change to my page – see the delivery tab in this url

    https://www.dev.niftymarketing.co.uk/chimney.co.uk/product/aarrow-ecoburn-plus-5kw/

    Any ideas?

    Also, if i wanted this table to appear on multiple pages, can i add multiple slugs into the php?
    Thanks….

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    just to be sure: Did you activate the Extension as a new WordPress plugin after installing it?

    Can you temporarily comment out that if-condition to see if the code is loaded then?

    You will then actually only need 'aarrow-ecoburn-plus-5kw' once in that array. There’s a small typo in the Extension’s code, that second page-slug-1 should have been page-slug-2, indicating how you’d add more pages to the list. It’s just a comma-separeted list.

    Regards,
    Tobias

    Thread Starter Mick37

    (@mick37)

    Hi Tobias

    Yes the extension is activated. I have commented out the if condition and now it works! The table is hidden and the search box is visible and when you enter a postcode, for example BN, the table appears only showing the rows that contain BN..

    that’s perfect, thank you!
    i will add additional slugs so i can use the functionality on multiple pages..
    And thanks for the really quick response..

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    that’s good to hear! Then we’ll just have to get the if-condition straight.
    It might be possible that is_page() is not the correct function here as your pages are actually Custom Post Types from WooCommerce, as far as I can see, right? You might therefore have use is_single() in the same fashion.

    Instead of using the slugs, you could also experiment with the IDs, e.g.

    if ( ! is_page( array( '660', ... ) ) ) {

    Best wishes,
    Tobias

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

    Hi TobiasBg,

    I’m not really the encoder type, and would really want to know how Mick37 was able to do the search option with the hidden tables.

    I have like 5 separate tables, and I wanted to have the search bar find the results from any of the 5 tables.

    I already downloaded the extension, and then got lost from there.

    Thanks so much!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    I’m afraid that what you want to achieve is not directly possible with this Extension ??

    It can only be used to hide the table for each search field, revealing it after the user has typed in a search term. To activate that feature, you’ll have to modify the PHP file in the downloaded Extension, and adjust the list of page slugs that contain the tables where you want to add this. After that, the Extension has to be installed just like a regular WordPress plugin and then has to be activated.

    Having a single search field for multiple tables would require modifications to this JS code, but unfortunately, I don’t have that readily available. Sorry.

    Regards,
    Tobias

    Hi TobiasBg,

    I think I understand how to add the tables, I still don’t know how to add just the search bar. ??

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    this will happen automatically, if your tables have the search feature enabled. So, before using the Extension, make sure that the regular features of the DataTables JS library (that you can configure on the table’s “Edit” screen) work.

    Regards,
    Tobias

    make sure that the regular features of the DataTables JS library (that you can configure on the table’s “Edit” screen) work.

    ?? When you say DataTables JS library, you mean the actual table right? Yes, it seems like all the features/configurations on each table work, and their search feature enabled.


    Question. If I want to make the tables still visible in their own pages, but want to have a search bar go through all of them from a front page search, does that mean I have to create a whole new table with all of the entries from the 5 tables?

    Super thanks Tobias! ??

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    Yes, the JS features of the actual table have to be turned on (at minimum, the search feature).

    And yes, if you create a table with the contents of all of those 5 tables, to be added to the front page, you could have a “combined” search field there.

    Regards,
    Tobias

    Great!

    One more question. please…

    Will I be able to change the name of my search bar into something else? Like “Find here” or “Enter code here”? If so, how? ??


    OMG! I owe you a trenta (bigger than a Starbucks venti coffee)

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    yes, changing the text is possible using e.g. the TablePress Extension from https://tablepress.org/extensions/change-datatables-strings/

    If your site uses the English version, an easier way would be to add this to the “Custom Commands” textfield on the table’s “Edit” screen:

    "language": { "search": "Enter code here: " }

    And thanks for wanting to donate, I really appreciate it.

    Regards,
    Tobias

    Hi again Tobias.

    Was able to do everything as you’ve instructed. But my search bar seems to be out of place. How do I move it to the left side?
    (See reference here:

    https://www.evernote.com/shard/s436/sh/6d442b6a-ffc0-4d4e-83a1-19b08741afde/32d97215e8012bd282fbd63ac9543718

    )

    Super thanks! ??

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    that should be possible with some “Custom CSS” on the “Plugin Options” screen, like

    #tablepress-123_filter {
      float: none;
    }

    where 123 is the table ID.

    Regards,
    Tobias

    P.S.: Could a moderator maybe fix the broken HTML in the previous post? Thanks a lot!

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘search a hidden table’ is closed to new replies.