• Resolved bdjenkin

    (@bdjenkin)


    Hi,

    I am trying to integrate the tables to display in search results. My question, is it possible to get the table ID from a post ID passed in a url
    ?post_type=tablepress_table&p=1030
    My plan is to then use tablepress_print_table () to print the table in the results. This would really help me out, thanks.

    https://wordpress.org/plugins/tablepress/

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

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    TablePress does integrate into the WordPress search already, actually, i.e. all tables that are embedded (with their Shortcode) into a post or page, will be searched.

    Regardless, you could maybe use the information in the tablepress_tables option (that you can load with get_option()). That contains an array with the table ID in the key and the post ID in the value.

    Regards,
    Tobias

    Thread Starter bdjenkin

    (@bdjenkin)

    Hi Tobias,

    Thanks for the quick response. I should have been more specific, I am using openSearchServer to index my site and the coordinating WP plugin to modify standard search. The URL snippet I posted before was the URL field from the oss-results, my plan is to print table as described in place of the oss generated content:
    [[“Click in this area to sort these files”],[“Accidental Hazardous Exposure”],[“Adverse Reaction Investigation Report”],[“Authorization Form “],[“Authorization Form (Spanish)”],[“Activity- IEB Eye Tissue Recovery”],[” Activity – Procurement “],[” Activity- Transport”],[“Attention Pickup…

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    ah, ok, I see.
    Yes, then extracting the table ID from the post ID might be the best option.

    Regards,
    Tobias

    Thread Starter bdjenkin

    (@bdjenkin)

    Thanks, just to clarify: do I call get_option() on the post_id?

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no, you use

    (array) json_decode( get_option( 'tablepress_tables' ), true );

    to get an array that contains the table ID to post ID relationship.

    Regards,
    Tobias

    Thread Starter bdjenkin

    (@bdjenkin)

    You are amazing! I got the search to display tables directly in the results. The only problem I have now is that I’m passing id=$table_id&use_datatables=true&print_name=false to tablepress_print_table but it still prints the table name… Any idea why that would happen?

    Thread Starter bdjenkin

    (@bdjenkin)

    Also, and I’m sorry if this is annoying you, it would great if there were a way to pass a parameter through tablepress_print_table that would pass to the table’s search field. That way I could narrow down the table’s contents to the term searched.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    good to hear that this is working!
    Instead of using the string parameter, I suggest to use the array version, which is more flexible and easier to read:

    tablepress_print_table( array(
      'id' = > $table_id,
      'print_name' => false,
      'use_datatables' => true,
    ) );

    I’m not sure about the table name though. Are you sure that that’s coming from the plugin and not maybe because it’s written above the Shortcode as text? Also, you should not really need those Shortcode parameters, if the corresponding checkboxes are set on the tables’s “Edit” screens.

    Regarding that filter parameter: You could use this TablePress Extension to only show the matching rows: http://tablepress.org/extensions/row-filter/
    Or, you could use this one http://tablepress.org/extensions/datatables-auto-filter/ to use the JS-based search.

    Regards,
    Tobias

    Regards,
    Tobias

    Thread Starter bdjenkin

    (@bdjenkin)

    I’m all set now, thank you again for help.

    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 10 replies - 1 through 10 (of 10 total)

The topic ‘Table ID from Post ID’ is closed to new replies.