Okay
  Public Ticket #3449812
Table query on Master Details Page
Closed

Comments

  • Toby Ivey started the conversation

    I am using wpDataTables and Master Detail Tables to try and set up my Hockey website.

    One of the things I'm trying to do is have a list of players (link above) and when you click on a row, have it open up details on that player, which will ultimately include things like their statistics, transactions and potentially other data from other tables

    What I did was setup the first table - Players, which then is accessible through the link above.  Then if you click on the first player (Lester Patrick), it will transfer you to the Profile Post, which will then populate his bio data.

    I then added a second table to the profile page (below the bio), which shows a view of the Transactions table, but I can't figure out how to pass the variable on to that table to only bring up transactions associated with the ID.

    RESOLVED: I was able to use the Master-Details variable (in this case the ID column which translates to %ID%) which I then included in the second table's WHERE statement in a similar fashion to the way that you would do %VAR1% etc.

    Additional to that question, I also have some fields that I only want to display in the details if they have a date value that isn't 0000-00-00, but I suspect I might have to use PHP code for that...unless there's any sort of conditional statements you can put on the field displays

  •  1,689
    Miloš replied

    Hi Toby,

    Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    -

    1. Thank you very much for sharing how you achieved the workaround in order to use the WHERE statement for that second table on the Master Details Template Page,

    and get a solution for the use case of filtering/pulling just the data for that particular player of the 'clicked row' from the 'Players' Table.

    We will make note of it, if other users might need the same solution.



    2. Yes.  For something like this, a condition to be "if the date value is not 0000-00-00",

    we currently don't have an easy solution with our built-in options/placeholders.

    This is an interesting idea for a future option, though, so if you can be so kind, you can add a development suggestion for us.


    Please feel free to search on our suggestions page

     to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there,  and as more people vote, the feature will move higher on the priority list.

    You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;

    and our newsletter, so you're informed about new features, bug fixes, freebies, etc.

    -

    If you have coding skills and wish to try to make a custom solution now,

    you can check out our available hooks for Developers on this documentation and see if you can find any hook that might help.

    Please be advised that custom solutions with hooks are not included in our support.

    You can also research resources such as Stack Overflow to see if any other user perhaps found a workaround.

    ( We do like to give examples for certain solutions, but for this use-case, we, unfortunately, don't have anything yet)

    Kind Regards, 

    Miloš Jovanović
    [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

  •  1,689
    Miloš replied

    Hi Toby,

    Actually i just found something that might be useful,

    at least as an example to get you started.

    This one is for 'using a Custom Placeholder'.


    Using the built-in features of the plugin will not be able to do this,

     however, there is a workaround using this hook:

    wpdatatables_before_get_table_metadata( $tableId )

    function testSetVar1toMNR($tableID){
          global $wdtVar1;
      //get data that you need
     // this is only a example you will need to remove this do_shortcode func and
     // insert custom logic to get data from DB that you need
      $lMNR = do_shortcode('[ihc-user field="CUSTOM_FIELD_column"]');
      //You can add some condition based on table id or something else
      if ($tableID == 1) {
       $wdtVar1 = $lMNR; //Set VAR1 custom parameter to column
      }
           }
    add_action('wpdatatables_before_get_table_metadata', 'testSetVar1toMNR');
    

    I hope this might help, if you wish to try a custom solution with our hooks for developers.

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [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

  • Toby Ivey replied

    No worries, I'm still very much in the learning curve with wpdatatables, so trying to figure what is out of the box, and what isn't.

    Just to provide a bit clear context for how I achieved this (for anyone else that's interested)

    I have a table of players, and I include all the information I want to pass to an individual profile page through Master-Details -> Open Page (note some fields are hidden):

    PLAYERS – OutsideTheGarden (onrocket.site)

    That brings up the individual profile page for the player

    PROFILE – OutsideTheGarden (onrocket.site)

    Which in turn populates a number of the fields that were posted (e.g. %Name% - equivalent to the column names in the Players page)

    Then I added shortcodes for the additional table and declared the %VAR1% as the key I wanted to query off (I used %ID%) in the second table

    Finally in the second table I set my WHERE clause to include [My Key]=%VAR1% in my case it turns out to be ID=%VAR1%

    I even used it for single field queries, by creating a table in wpdatatables that only pulled that related information (kind of a workaround way to use single field short codes for dynamic tables), although there are some formatting challenges that I'd have to work through custom CSS to solve, as the table still has some padding even when you remove the borders and all

    Maybe will be helpful to some others

    On the other topic I'll keep poking around to see if I can find another option that will satisfy me without having to resort to too much code (which I would then have to maintain too)

  •  1,689
    Miloš replied


    Hi Toby,

    Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    -
    Thank you very much for sharing your workaround solution for this use case with us,

    and of course with other users,

    who can find this Public Ticket if they search for the appropriate key words on our Platform.

    We will certainly make a note of this,

    and our developers will do their best to improve the plugin in the future to have easier out of the box options for this,

    as well as to add more custom examples in the Documentation for developers section.

    Thanks again

    and of course, in the meantime if anything else comes up, don't hesitate to open additional/new tickets

    Kind Regards, 

    Miloš Jovanović
    [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