The project I am working on is covered by an NDA, so I cannot provide access or otherwise show much...
I have successfully pointed my table to a JSON file. This allowed me to set up and style the table (it looks terrific!). Now I want to pass the JSON dynamically in some fashion (variable? hook to an action?).
The steps are roughly this:
1) User navigates to a page to upload a file (via WPForms).
2) File is saved on the site.
3) Hooked WPForms action redirects to a page at which the table will be viewed.
4) Hooked action from WPForms accesses the file, converts to Base64, then posts to an external serverless function endpoint (AWS Lambda).
5) Function processes file, returning (in the response body) JSON formatted in accordance with the sample JSON I used to create the table.
6) JSON is (somehow) passed to wpDatatables which populates the table with that data.
It would seem there are two options here: a) Call the shortcode with the JSON string in %VAR1%; or a) hook into a wpDatatables action and replace the JSON data from the template file with the JSON data returned by the AWS Lambda function...
Which way is best. Can you provide some code example?
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.
-
When working with JSON format please note: Currently, wpDataTables accepts this, and only this, format of JSON (see example): a one-level array of same-structured objects where each object will be parsed as a row, and each field inside of the object as a cell. If your software does not return this format, you would need to prepare, as an example some PHP adapter to return one of the formats that wpDataTables would accept.
-
To be completely honest, the scenario you described here goes beyond my level of expertise, i can see that this requires a developer's level of knowledge,
so i have to escalate this to my senior colleagues at the 2nd level Team.
As soon as they respond i will come back to you regarding this question.
Sorry that it took so long, i got confirmation about this from our developers.
We suggest to create a PHP Adapter, and instead of JSON to use a PHP Array.
-
There is a hook available in the Premium version, but not in Lite:
wpdatatables_filter_url_php_array
In hook, you will do something like this
function test ($url,$id) {
// all data from current user
// you can fetch only what you need
$userData = wp_get_current_user()->data;
if(isset($userData)){
$url .= '?' . http_build_query($userData);
}
return $url;
}
add_filter('wpdatatables_filter_url_php_array', 'test', 2 , 10
In the PHP file, you will use the $_GET method to take the values from the URL which is filtered with the hook
// you can check then for ID or user_login or user_pass or user_nicename or user_email ...
if(isset($_GET['user_login'])){
//do somthing
}
I try to be detailed as I can so you can do this easily.
The project I am working on is covered by an NDA, so I cannot provide access or otherwise show much...
I have successfully pointed my table to a JSON file. This allowed me to set up and style the table (it looks terrific!). Now I want to pass the JSON dynamically in some fashion (variable? hook to an action?).
The steps are roughly this:
1) User navigates to a page to upload a file (via WPForms).
2) File is saved on the site.
3) Hooked WPForms action redirects to a page at which the table will be viewed.
4) Hooked action from WPForms accesses the file, converts to Base64, then posts to an external serverless function endpoint (AWS Lambda).
5) Function processes file, returning (in the response body) JSON formatted in accordance with the sample JSON I used to create the table.
6) JSON is (somehow) passed to wpDatatables which populates the table with that data.
It would seem there are two options here: a) Call the shortcode with the JSON string in %VAR1%; or a) hook into a wpDatatables action and replace the JSON data from the template file with the JSON data returned by the AWS Lambda function...
Which way is best. Can you provide some code example?
Hi, John Horst
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.
-
When working with JSON format please note: Currently, wpDataTables accepts this, and only this, format of JSON (see example): a one-level array of same-structured objects where each object will be parsed as a row, and each field inside of the object as a cell. If your software does not return this format, you would need to prepare, as an example some PHP adapter to return one of the formats that wpDataTables would accept.
-
To be completely honest, the scenario you described here goes beyond my level of expertise, i can see that this requires a developer's level of knowledge,
so i have to escalate this to my senior colleagues at the 2nd level Team.
As soon as they respond i will come back to you regarding this question.
Thank you for your patience.
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 | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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
Hi, John
Sorry that it took so long, i got confirmation about this from our developers.
We suggest to create a PHP Adapter, and instead of JSON to use a PHP Array.
-
There is a hook available in the Premium version, but not in Lite:
In hook, you will do something like this
In the PHP file, you will use the $_GET method to take the values from the URL which is filtered with the hook
I try to be detailed as I can so you can do this easily.
Let me know is it working as you need
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 | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia 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