Okay
  Public Ticket #2657666
Form inputs for placeholders
Closed

Comments

  • Jiahua started the conversation

    Hi Team, 

    Would like to find out if there's any way to use form inputs for the %VAR1%, %VAR2%, %VAR3% placeholders rather than to have them within the short code

    We want to allow the user to filter records by a date range, but the the actual date to be queried is embedded within an aggregated query. 

  •  2,507
    Aleksandar replied

    Hello Alvin

    I am sorry to disappoint you, but unfortunately something like this is not possible with the plugin's built-in features.

    Can you please explain in a bit more detail (and with an example, preferably) what you're trying to achieve?

    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

  • Jiahua replied

    Hi Aleksandar, 

    Our users need to filter the report by a date range. 

    I understand that there is already a built in date range filter in WP data tables but we are not able to use that as our date is not output as a field as it is an aggregated query

    e.g. 

    SELECT country, AVG(Score)

    FROM results

    GROUP BY country

    WHERE attemptdate > $VAR1 AND attemptdate <$VAR2. 








  •   Aleksandar replied privately
  •  1
    Axel replied

    Alvin

    I used wpdatatables_before_get_table_metadata to set a range of dynamic variable dates in a page:
    $ wdtVar1 and $ wdtVar2 which I then used with "between"% VAR1% "AND"% VAR2% "in the sql query.

    Take a look to this ticket:

    tmsplugins.ticksy.com//ticket/2578862/

    I hope this can help you

  •  2,507
    Aleksandar replied

    Thanks for your assistance here, Axel

    I did forward a different advice to Alvin, here, in a private response. I'll post it again publically, in case anyone needs it:

    You may have a use of using dynamic query with placeholders here.

    You do need some experience with writing SQL queries and using WP hooks.

    If you have a table with query for example

    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

    and then on your_custom_page you will insert shortcode of the tableid that you need with placeholder like this

    [wpdatatable id=1 var1=1]

    of course, you will create that second table from query like

    SELECT * FROM second_table WHERE user_id = %VAR1%

    and then you will use our hook for dynamic upsetting 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');


    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