{"id":89,"date":"2011-02-17T12:59:19","date_gmt":"2011-02-17T17:59:19","guid":{"rendered":"http:\/\/cfdbplugin.com\/?page_id=89"},"modified":"2016-12-15T21:56:22","modified_gmt":"2016-12-16T02:56:22","slug":"shortcodes","status":"publish","type":"page","link":"https:\/\/cfdbplugin.com\/?page_id=89","title":{"rendered":"Shortcode Basics"},"content":{"rendered":"<h1><strong>Shortcode Basics<\/strong><\/h1>\n<p>The following shortcodes are provided:<\/p>\n<ul>\n<li>[cfdb-datatable]<\/li>\n<li>[cfdb-table]<\/li>\n<li>[cfdb-json]<\/li>\n<li>[cfdb-value]<\/li>\n<li>[cfdb-count]<\/li>\n<li>[cfdb-html]<\/li>\n<\/ul>\n<p>All of these shortcodes provide a set of common options, so they are documented here. We will use [cfdb-table] in our examples, but understand it applies to all shortcodes.<\/p>\n<h2><strong><a name=\"form\"><\/a>Simplest Shortcode Example<\/strong><\/h2>\n<p>You have a form named &#8220;myform&#8221; and you want to display all its rows and columns in a page or post:<\/p>\n<ul>\n<li><code>[cfdb-table form=\"your-form\"]<\/code><\/li>\n<\/ul>\n<p>This shows the whole table with CSS provided by the plugin. See the page on <a href=\"http:\/\/cfdbplugin.com\/?page_id=93\">[cfdb-table]<\/a> to learn more about how to apply your own styles.<\/p>\n<h2><strong><a name=\"show\"><\/a><a name=\"hide\"><\/a>Choosing which Columns to Display with &#8220;show&#8221; and &#8220;hide&#8221;<\/strong><\/h2>\n<ul>\n<li><code>[cfdb-table form=\"myform\" show=\"field1,field2,field3\"]<\/code> (optionally show selected fields)<\/li>\n<li><code>[cfdb-table form=\"<\/code><code>myform\" hide=\"field1,field2,field3\"]<\/code> (optionally hide selected fields)<\/li>\n<li><code>[cfdb-table form=\"your-form\" show=\"f1,f2,f3\" hide=\"f1\"]<\/code> (hide trumps show, f1 will be hidden)<\/li>\n<\/ul>\n<p>As of version 1.8, &#8220;show&#8221; and &#8220;hide&#8221; now support regular expressions to be able to specify column names. Regular expression match according to <a href=\"http:\/\/php.net\/manual\/en\/function.preg-match.php\" target=\"_blank\">preg-match<\/a>.<\/p>\n<p>Examples:<\/p>\n<ul>\n<li><code>[cfdb-table form=\"myform\" show=\"\/.*name\/\"]<\/code> (shows all fields whose name ends with &#8220;name&#8221; such as &#8220;first-name&#8221; and &#8220;last-name&#8221;)<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" show=\"\/.*name\/i\"]<\/code> (Same as previous, but is a case-insensitive match. So &#8220;Last-Name&#8221; as well as &#8220;last-name&#8221; match)<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" hide=\"\/Submitted.*\/\"]<\/code> (Don&#8217;t show fields starting with &#8220;Submitted&#8221;)<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" hide=\"message,\/Submitted.*\/,\/Cookie.*\/\"]<\/code> (Don&#8217;t show (1) the &#8220;message&#8221; field, (2) \u00a0fields starting with &#8220;Submitted&#8221;, (3) fields starting with &#8220;Cookie&#8221;. If you have the option on to capture users&#8217; Cookies with their form submissions, use hide=&#8221;\/Cookie.*\/&#8221; to hide them. )<\/li>\n<\/ul>\n<ul>\n<li>Remember that is you have both &#8220;show&#8221; and &#8220;hide&#8221; specified, any field that match both will be hidden. That is, &#8220;hide&#8221; trumps &#8220;show&#8221;.<\/li>\n<\/ul>\n<h2><strong><a name=\"role\"><\/a>Adding Security With &#8220;role&#8221;<\/strong><\/h2>\n<p>(As of version 2.4.1) The &#8220;role&#8221; attribute can limit the short code to only create output for logged-in users with a minimal user role. Set the &#8220;role&#8221; attribute to one of:<\/p>\n<ul>\n<li>Administrator<\/li>\n<li>Editor<\/li>\n<li>Author<\/li>\n<li>Contributor<\/li>\n<li>Subscriber<\/li>\n<li>Anyone<\/li>\n<\/ul>\n<p>Example: if <code>role=\"Editor\"<\/code> is used, then a user logged in with role Author, Contributor or Subscriber sees no output. A user logged in who has role Editor or Administration will see the output. Editor and Administration users who are not logged in will see no output.<\/p>\n<p><strong>WARNING<\/strong>: This security setting is overridden by the plugin-wide setting that limits what roles can see data from short codes. In the WP Admin area, go to <strong>Contact<\/strong> -&gt; <strong>Database Options<\/strong> -&gt; <strong>Can See Submission when using shortcodes<\/strong>. If that setting is set to &#8220;Author&#8221; for example, then no user will less than Author role can see output from any short code even if you have <code>role=\"Anyone\"<\/code> in a short code. You may find it most useful to set the plugin-wide setting to &#8220;Anyone&#8221; then use &#8220;role&#8221; on your short codes. The plugin-wide setting is there to allow an administrator to prevent Contributers, Authors and Editors from writing short codes in posts that might reveal data that they are not permitted to see.<\/p>\n<p>Notes:<\/p>\n<ul>\n<li>The Anyone role implies that users do not have to be logged in to see the short code output<\/li>\n<li>Case Counts. Be sure to capitalize the first letter of the role names<\/li>\n<li>If you set <code>permissionmsg=\"true\"<\/code> then an error message will show on your page when a user does not have permission. By default, if &#8220;role&#8221; is being used, no permission error is shown.<\/li>\n<\/ul>\n<h2><strong><a name=\"permissionmsg\"><\/a>Hiding Permission Message with &#8220;permissionmsg&#8221;<\/strong><\/h2>\n<p>(As of version 2.4.1) In cases where a user does not have adequate permission to view the output of a short code, in place of the short code output, the following message is displayed:<\/p>\n<blockquote><p>You do not have sufficient permissions to access this data.<\/p><\/blockquote>\n<p>If you wish to have no message displayed, set <strong>permissionmsg=&#8221;false&#8221;<\/strong> in your short code.<\/p>\n<h2><strong><a name=\"limit\"><\/a>Limiting How Many Rows to Display with &#8220;limit&#8221;<\/strong><\/h2>\n<p>Say you just want the first 10 rows, not every form submission. Use &#8220;limit&#8221;<\/p>\n<ul>\n<li><code>[cfdb-table form=\"myform\" limit=\"10\"]<\/code> (shows only the first 10 rows)<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" limit=\"0,10\"]<\/code> (shows only the first 10 rows starting with row #0 which is the first row. This is the same as just using limit=&#8221;10&#8243;)<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" limit=\"10,10\"]<\/code> (shows only the first 10 rows <span style=\"text-decoration: underline;\">starting <\/span>with row #10. In other words, this shows rows #10-19. The previous example shows rows #0-9. So this is like the next page of 10 rows.<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" limit=\"20,10\"]<\/code> (shows only the first 10 rows\u00a0starting\u00a0with row #20. In other words, this shows rows #20-29. The previous example shows rows #10-19. So this is like the next page of 10 rows.<\/li>\n<\/ul>\n<h2><strong><a name=\"random\"><\/a>Choosing Random Rows to Display with &#8220;random&#8221;<\/strong><\/h2>\n<p>(Available in version 2.4) In cases where you would like to select random rows from those being returned, indicate the number of rows to be returned using &#8220;random&#8221;.<\/p>\n<div>In these examples, assume there are columns (form fields) named &#8220;lastname&#8221; and &#8220;firstname&#8221;<\/div>\n<ul>\n<li><code>[cfdb-table form=\"myform\" random=\"1\"]<\/code>\u00a0(return 1 random row)<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" random=\"2\" search=\"Michael\"]<\/code>\u00a0(return two random rows that met the search criteria)<\/li>\n<\/ul>\n<div>The &#8220;random&#8221; option will show the number of rows you request, or less if less rows are returned from the query. For example, if you have random=&#8221;10&#8243; but the short code can only return 5 rows, then 5 are shown.<\/div>\n<h2><a name=\"orderby\"><\/a>Sorting by One or More Columns with &#8220;orderby&#8221;<\/h2>\n<div>By default, the results are returned in order of their submission date descending. In other words, the most recent submission entry is first, followed by the next most-recent and so on. But you may want to sort by last name for example. In that case use &#8220;orderby&#8221;.<\/div>\n<div>In these examples, assume there are columns (form fields) named &#8220;lastname&#8221; and &#8220;firstname&#8221;<\/div>\n<ul>\n<li><code>[cfdb-table form=\"myform\" orderby=\"lastname\"]<\/code> (Sort by lastname column)<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" orderby=\"lastname,firstname\"]<\/code> (Sort by lastname and for those with the same lastname, sort by firstname)<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" orderby=\"lastname desc\"]<\/code> (Sort by lastname column in descending (reverse) order. That is, the &#8220;Z&#8217;s&#8221; come first)<\/li>\n<\/ul>\n<ul>\n<li><code>[cfdb-table form=\"myform\" orderby=\"lastname desc,firstname desc\"]<\/code> (Reverse-sort by lastname and for those with the same lastname, reverse-sort by firstname)<\/li>\n<\/ul>\n<p>You can use &#8220;asc&#8221; for ascending sort or &#8220;desc&#8221; for descending sort. But &#8220;asc&#8221; is assumed if not specified.<\/p>\n<h2><a name=\"search\"><\/a>Choosing which Rows to Display with &#8220;search&#8221;<\/h2>\n<p>The search field acts like the dynamic Search field that appears on the DataTable. It selects rows where any cell contains the search text (case in-sensitive).<\/p>\n<ul>\n<li><code>[cfdb-table form=\"your-form\" search=\"Washington\"]<\/code> (show only rows where any field contains &#8220;Washington&#8221; in any case, so &#8220;washington&#8221; also matches)<\/li>\n<\/ul>\n<h2><a name=\"filter\"><\/a>Choosing which Rows to Display with &#8220;filter&#8221;<\/h2>\n<p>Filter provides a much more specific and complex way to specify rows to show. Unlike &#8220;search&#8221;, &#8220;filter&#8221; specifies searches on specific columns.<\/p>\n<ul>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1=value1\"]<\/code> (show only rows where field1=value1)<\/li>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1=null\"]<\/code> (SPECIAL CASE: &#8216;null&#8217; is interpreted as null-value (field does has no value)<\/li>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1!=value1\"]<\/code> (show only rows where field1!=value1)<\/li>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1=value1&amp;&amp;field2!=value2\"]<\/code>(Logical AND the filters using &#8216;&amp;&amp;&#8217;)<\/li>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1=value1||field2!=value2\"]<\/code>(Logical OR the filters using &#8216;||&#8217;)<\/li>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1=value1&amp;&amp;field2!=value2||field3=value3&amp;&amp;field4=value4\"]<\/code>(Mixed &amp;&amp;, ||. Standard Boolean operator precedence applies (ANDs are evaluated, then ORs)<\/li>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1~~\/^a\/\"]<\/code> (Regular expression; shows rows where field1 starts with &#8216;a&#8217;)<\/li>\n<\/ul>\n<h3>Filtering Rows: Supported Filter Operators<\/h3>\n<ul>\n<li><code>=<\/code> and\u00a0<code>==<\/code> are the same<\/li>\n<li><code>!=<\/code>,\u00a0<code>&lt;&gt;<\/code> are the same<\/li>\n<li><code>&gt;<\/code>,\u00a0<code>&lt;<\/code>,\u00a0<code>&lt;=<\/code>,\u00a0<code>&gt;=<\/code><\/li>\n<li><code>===<\/code> and\u00a0<code>!==<\/code><\/li>\n<li><code>~~<\/code> for regular expressions<\/li>\n<li>[in], [!in] for &#8220;in list&#8221; such as:\n<ul>\n<li><code>filter\"=lastname[in]Simpson,Smith,Jones\"<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Filtering Rows: Filter by Regular Expressions<\/h3>\n<ul>\n<li>Use the\u00a0<code>~~<\/code> operator, and Perl-style delimiters around the pattern, such as\u00a0<code>\/<\/code><\/li>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1~~\/^a\/\"]<\/code> (shows rows where field1 starts with &#8216;a&#8217;)<\/li>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1~~\/.*@gmail.com\/i\"]<\/code> (shows rows where field1 is a Gmail address, case-insensitive)<\/li>\n<li>FYI: uses\u00a0<a title=\"preg_match\" href=\"http:\/\/php.net\/manual\/en\/function.preg-match.php\">preg_match<\/a> to evaluate the regex<\/li>\n<\/ul>\n<h3>Filtering Rows: How to make &#8220;filter&#8221; Work Like &#8220;search&#8221;<\/h3>\n<p>Given &#8220;search&#8221; example:<\/p>\n<ul>\n<li><code>[cfdb-table form=\"your-form\" search=\"Washington\"]<\/code>\u00a0(Searches ALL fields)<\/li>\n<\/ul>\n<p>When using &#8220;filter&#8221; use regular expressions with case-insensitive option (&#8220;i&#8221;), listing all fields.<\/p>\n<ul>\n<li><code>[cfdb-table form=\"your-form\" filter=\"field1~~\/.*washington.*\/i||field2~~\/.*washington.*\/i\"]<\/code>\u00a0(searches field1 and field2. You have to put a regex search for all the fields you want to search when using &#8220;filter&#8221;, strung together with logical ORs &#8220;||&#8221; )<\/li>\n<\/ul>\n<h3>Filtering Rows: Filter Limitations<\/h3>\n<ul>\n<li>Does not support parentheses to control the order of boolean evaluation<\/li>\n<\/ul>\n<h3>Filtering based on Relative Time Using submit_time<\/h3>\n<p>For the &#8220;submit_time&#8221; field only, you can use special time values like:<\/p>\n<ul>\n<li><code>[cfdb-table form=\"your-form\" filter=\"submit_time&gt;last week\"]<\/code>\u00a0(shows all submissions since last week)<\/li>\n<\/ul>\n<p><a href=\"http:\/\/cfdbplugin.com\/?page_id=553\">Read more<\/a>.<\/p>\n<h3>Filtering Rows: Variable Substitution<\/h3>\n<p>Advanced options are discussed in\u00a0 <a href=\"http:\/\/cfdbplugin.com\/?page_id=116\">Filter Variable Substitution<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Shortcode Basics The following shortcodes are provided: All of these shortcodes provide a set of common options, so they are documented here. We will use in our examples, but understand it applies to all shortcodes. Simplest Shortcode Example You have a form named &#8220;myform&#8221; and you want to display all its rows and columns in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1577,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"page-without-sidebar.php","meta":{"footnotes":""},"class_list":["post-89","page","type-page","status-publish","hentry"],"jetpack_shortlink":"https:\/\/wp.me\/P1mptf-1r","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":23,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/89\/revisions"}],"predecessor-version":[{"id":1579,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/89\/revisions\/1579"}],"up":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/1577"}],"wp:attachment":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}