Problem: I have a View that filters based on shortcode attributes. I would like use a JavaScript templating library like Handlebars to set the View's shortcode attribute with data from a JSON object that exists on the page when the page loads.
Solution: Unfortunately there is no JavaScript API for forms, so there is not an easy way to set a shortcode attribute value with JavaScript after the View has loaded. If the JSON data is available in PHP before the page loads, then you may be able to use the PHP API render_view to set the desired attribute value and render the View programmatically instead of using the wpv-view shortcode:
$args = array( 'name' => 'grab-categories', 'billid2' => 'some value' ); echo render_view( $args );
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-api/#render_view
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 4 years, 10 months ago.
Assisted by: Christian Cox.