Nesting Short Codes
(As of version 2.2.4)
The [cfdb-html] short code now will allow you to nest short codes within it. This can be any tag you like, but there is a special case where you can nest a different tag from this plugin.
Example:
1 2 3 4 | [cfdb-html form="My Form"] Here is a table submitted at ${Submitted} [cfdb-table form="My Form" filter="submit_time=${submit_time}"] [/cfdb-html] |
In this case we nest a [cfdb-table] inside the [cfdb-html]. The special thing that we do is give the submit_time from the outer [cfdb-html] to the inner [cfdb-table]. Remember that [cfdb-html] prints out its template for every entry found in the database and replaces ${field-name} type values with the field values for each entry. In this case, we effectively pass the submit_time (a form submission unique id) from each [cfdb-html] entry to a [cfdb-table] short code via filter=”submit_time=${submit_time}”. The [cfdb-table] short code will find just that one element each time.
This can be inefficient because [cfdb-html] does a query, then for each entry found, [cfdb-table] does a query. A more efficient solution is to follow the technique in Create Your Own Short Code.
NOTE: because of a limitation of WordPress, you cannot nest a [cfdb-html] inside a [cfdb-html]