Okay
  Public Ticket #2765836
Dynamically linking to other tables
Closed

Comments

  • Bruce started the conversation

    Hi,

    My client has a requirement to be able to dynamically join related data via hypertext links.  Does your software support this functionality?

    Regions (R_ID PK) -> Region Events (RE_ID PK, R_ID FK) -> Region Event Results (RER_ID PK, RE_ID FK)

    If so, can you please direct me to the proper documentation the explains how to implement that.

    It appears that your Master Detail Add-on only allows access to additional fields within a table's record rather than allowing access to additional fields within one or more records in a joined table.

    Thanks

    Bruce

  •  2,498
    Aleksandar replied

    Hello Bruce

    I'm sorry, but dynamically linking tables like this is not possible without some custom work.

    If we assume you created a table using this query:

    SELECT user_id, user_name, user_address,
    CONCAT('<a href="http:/yoursite.com/your_custom_page?user_id=',user_id,'">Details</a>') AS Details
    FROM your_table_name

    Then, on your_custom_page you will insert a shortcode of the table ID that you need, with a placeholder like this:

    [wpdatatable id=1 var1=1]

    The second table would be created from a query like this:

    SELECT * FROM second_table WHERE user_id = %VAR1%

    After that, you can use a hook for dynamic placeholders:

    function updateVAR1($tableID){  global $wdtVar1;
          //check is set GET parametar user_id
        if(isset($_GET['user_id'])){
            //get value from form fieald
            $wdtVar1 = $_GET['user_id'];
        }
      }
    add_action('wpdatatables_before_get_table_metadata', 'updateVAR1');

    This is the only way of using dynamic queries with the plugin, at the moment.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Bruce replied

    Very helpful!

    Thanks!