Okay
  Public Ticket #3817558
Shortcode
Open

Comments

  • Dmitry started the conversation

    Good day!

    Hello! I have several related tables that use a variable for linking, %VAR1%. For example:

    SELECT country, percentage_share FROM wp_trad_export_countries WHERE company_id = '%VAR1%'
    

    I created these tables, but I can't get them to work correctly on the page.

    I'm using the shortcode:

    [wpdatatable id=1 var1="{GET.cID}"]  

    But the table doesn't recognize the GET value. It says that no data is available.

    However, if I insert the actual cID value into the shortcode, for example:

    [wpdatatable id=1 var1=21011]  

    The tables display everything perfectly!

    I've already tried using a PHP request, removing and adding quotes, curly brackets—nothing helps!

  •  1,873
    Miloš replied

    Hi Dmitry,

    A usual use case of how our VAR placeholders are used is to set a specific cell value on the back-end table settings/Placeholders as the actual %VAR1%.

    That value must exist in one of the table rows in order for the table to generate at the back end.
    It seems you covered that part correctly since the table is loading on the back end, right?


    2. But, this way of how you are trying to pull a GET value, I think it can not be used in that way at the moment.

    Of course, as you pointed out, if you pass an actual cell value in the var1 via the Shortcode, that works as intended.

    I will ask our QA Team/ and the developers, to see if we have any workaround idea of what you might try.

    Can you please elaborate in more details, as to where that {GET.cID} value is coming from, so that our developers can have a clear picture of the use case?

    You can add a Video or screenshots to clarify it as much as possible.
    If it shows any sensitive data, just send it as a PRIVATE reply, for security reasons.

    And if a Video gets too large, you can upload it to weTransfer and send a download link.

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    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

  • Dmitry replied

    Good afternoon! Thank you for your response!

    I have created several tables:

    Companies:
    • Export_Countries: Columns: Company_id, name, address, created_at.

    In WPDataTables, I created the following table:

    SELECT *  FROM trad_companies AS tc  WHERE company_id = '%VAR1%'  AND created_at = (      SELECT MAX(created_at)      FROM trad_companies      WHERE company_id = tc.company_id  );
    

    Columns: company_id, country, percentage_share.

    Another table in WPDataTables:

    SELECT country, percentage_share  FROM trad_export_countries  WHERE company_id = '%VAR1%'  

    And so on.

    The company_id in the first table matches the company_id in the second table.

    Then, in Elementor, I added the shortcode:

    [wpdatatable id=1 var1="{GET.cID}"]  

    In the address bar, I need to specify the Company_id value.

    However, the table does not see this value! When I manually inserted a real value into the shortcode:

    [wpdatatable id=1 var1="20250"]  

    The table worked!

    I somehow managed to work around this issue using SQL, but the problem still exists! This is an extremely important function—to read values from the GET parameter!

    Now, I have created a map, and when the link (/?page_id=2516&shipper_country_name=canada) is opened, a specific country should be displayed from the table. How can this be done if WPDataTables does not work with GET? This is unbelievable!

    How can I pass information between pages?

  •  1,873
    Miloš replied

    Hi Dmitry,

    My apologies for all the waiting time. Thank you for your patience.

    In regards to this use-case, thank you for further details.

    Yes, this is not a standard scenario for our VAR placeholder, it is not designed to be used like that 'out of the box'.

    So, when you provide a VAR value via the table's shortcode, that needs to be an actual value, rather than 'nesting' a GET variable inside our VAR placeholder.


    So, as explained in the Documentation hyperlinked above, on how our built-in VAR1 placeholder works;
    You can set anything you wish as the 'default VAR1' in the table's back-end, but that needs to be an actual value which exists in the table's cell, in order for the table to generate on back end.

    Then, via the table shortcode, you can pass a different cell value from the Table as VAR1, but as you found, that needs to be an actual value existing in a table's cell.


    That is why, in your case this works :

     

    [wpdatatable id=1 var1="20250"]  

    And this does not work :

    [wpdatatable id=1 var1="{GET.cID}"]  

    Because, as far as I see it, you are trying to "nest" a variable from the GET inside our own VAR1 placeholder and at the moment, we don't have a way to solve it exactly like that.

    That feature is designed in the way to provide an actual cell value, rather than to 'tell' our Plugin to 'see it from the GET value' as you would prefer in the specific use case.

    - If you wish to see a built-in solution for this scenario, you can make a future development suggestion :

    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.

    We also added this new developer's handbook, which can allow users with coding skills to make custom add-ons.

    Our developers will keep adding more custom hooks/examples there over time.

     

    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.


    There could be a possible custom example, I will share it with you, here is how you can create your own 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 can't say if this will work exactly as you need it for this use-case, to pick up the value from your GET parameter, but I hope it helps.


    2. In regards to passing a filter parameter for a table's column via URL, please checkout this feature : Pre-filtering tables through URL.

    I hope that helps.



    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    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