Filtering the information in the DS controls, with URL’s parameters

We’ve published an update of “Calculated Fields Form” plugin, Developer version (v 5.0.59), that includes the feature for filtering the data to prepopulate the “DS” Controls, with javascript’s variables.

The “DS” Controls, are represented with the letters “DS” in their names, and their data is pre-populated from external data sources (like databases, posts data, taxonomies, CSV files, or users data)

I’ll try to explain the new feature through an example:

Suppose you want to insert a “Line Text DS” field on form with the title of the post where the form has been inserted, so, the query would be something like:

SELECT post_title as value FROM wp_posts WHERE ID=post_id_here

By default the post’s id is passed as an URL parameter: p=post_id_here

In our plugin, the parameters are converted in javascript variables with the shortcode:

[CP_CALCULATED_FIELDS_VAR name=”parameter_name”]

So, you should insert in the content of page the shortcode: [CP_CALCULATED_FIELDS_VAR name=”p”], and the plugin will create the javascript variable: “p” with global scope.

The previous versions of the plugin only accept the use of fields names for filtering the data from data sources. So, if you want to use the “p” variable to get the corresponding post’s title from database, you should to use a “Calculated Field” as auxiliary field, its equation would be as simple as the variable’s name: p, and if the name of field is for example: fieldname1, the query to use would be like follow:

SELECT post_title as value FROM wp_posts WHERE ID=<%fieldname1%>

With the latest version of the plugin the process is simpler, you don’t need any auxiliary field, because you can use the variable’s name directly in the query, you simply should close the variable name between the symbols: <%var_name%>, similar to the previous versions of the plugin with the fields names. Finally, the query would be:

SELECT post_title as value FROM wp_posts WHERE ID=<%p%>

Comments are closed, but trackbacks and pingbacks are open.