[cfdb-html]

December 15th, 2016

This documentation applies to version 2.6 and later

Summary of Shortcode Options

Option Example Description
form [cfdb-html form="myform"] Required. Designates the form to display. All rows and columns are displayed by default
role [cfdb-datatable form="myform" role="Author"] Make short code only display output for user’s with minimum-required role. Choices are

  • Administrator
  • Editor
  • Author
  • Contributor
  • Subscriber
  • Anyone

WARNING: this setting is overridden by plugin setting in WP Admin page Contact -> Database Options -> Can See Submission when using shortcodes
(since 2.4.1)

show [cfdb-html form="myform" show="col1,col2"] Limits columns to be shown to be those designated (comma-delimited list)
hide [cfdb-html form="myform" hide="col1,col2"] Does not show listed columns (comma-delimited list)
limit [cfdb-html form="myform" limit="10"] One number: limit=”10″ means show first 10 rows. Is the same as limit=”0,10″ Two Numbers: limit=”100,10″ means show 10 rows starting at row #100)
random [cfdb-table form="myform" random="2"] Display 2 random rows from those that the short code finds. (Since 2.4)
orderby [cfdb-html form="myform" orderby="last-name,first-name"] Sort rows by designated columns. Use “column-name desc” to sort in descending (reverse) order
search [cfdb-html form="myform" search="Simpson"] Select rows to display that have any cell with the search text in it (case insensitive). Intended to mimic behavior of the “Search” field in the DataTable
filter [cfdb-html form="myform" filter="col1=Simpson"] Select which rows to display based on filter expression. More powerful than “search”, it can filter on multiple columns with boolean and regular expressions. If both “search” and “filter” are specified, “search” is ignored.
Options specific to this shortcode
filelinks [cfdb-html form="myform" filelinks="img"] Select how uploaded file fields should be output.
Options are

  • url – output URL to download file
  • name – outputs simple file name
  • link – outputs and HTML link (“a” tag) linking to download the file
  • img or image – assumes the file is an image file and embeds the image in page (“img” tag)
stripbr [cfdb-html form="myform" stripbr="true"] *** Available as of 2.1 ***”Strip BR tags”. This is an alternative to wpautop which often does not work. If this option is set to “true” then all “<br />” tags will be removed from the output. The intention is to strip out BR tags injected by the WordPress  wpautop function.The unintended consequence may be that it strips out BR tags that you put in the HTML template of this tag. The trick to make that work is to put in BR tags without a space, that is “<br/>” or use capital letters. This option only removes BR tags that exactly match  “<br />”You might also consider using a plugin to turn off wpautop for a specific post. In that plugin, you set a customer field on the post to turn off wpautop
wpautop [cfdb-html form="myform" wpautop="true"] *** THIS MAY NOT WORK IN RECENT VERSIONS OF WORDPRESS ****** DEPRECATED AS OF VERSION 2.1. USE “stripbr” OPTION INSTEAD ***
Turn on or off wpautop for the short code. Valid values are “true” or “false”. If not specified, “false” is the default. WP likes to automatically inject HTML P and BR tags into content text to try to reflect where users have typed in line breaks. This is called wpautop. This affects the content/template text this shortcode (the text between the open and close tags). If you are not putting HTML tags in that content, you might wish to set wpautop=”true” to have WP preserve your line breaks. But if you are putting in your own HTML, then you will likely want wpautop=”false” to prevent WP from injection extraneous BR and P tags into your markup.

Want to get your data into an HTML format that you want instead of in a table and not in Javascript/JSON? This is the shortcode for you.

Template
Best explained with an example. Imagine an example similar to showing WordPress blog entries. If you imagine that a form submission is a blog entry, you could use this shortcode to show the most recent 10 blog entries.

[cfdb-html form="blogs" show="name,title,blogtext" limit="10" orderby="Submitted desc"]

<div class="your-headline-style">${name}: ${title}</div>

<div class="your-content-style">${blogtext}</div>

[/cfdb-html]

Unlike other shortcodes, we use the begin-tag [cfdb-html]Template [/cfdb-html] end-tag format. The template content inside the tag is repeated for each row returned by the shortcode.

You use the ${column-name} syntax to show where values for each row should be inserted. Be sure that all such substitution names are in your “show” list, or simply omit “show”.

Use filelinks to indicate how form files that are uploaded files should be treated.

Options are:

  • url – output URL to download file
  • name – outputs simple file name
  • link – outputs and HTML link (“a” tag) linking to download the file
  • img or image – assumes the file is an image file and embeds the image in page (“img” tag)

Before and After
(Since 2.8)
A optional “before” and “after” section can be added which gets output once immediately before and after the template section respectively. Remember: the template gets output once for each form entry.

This can be useful for adding addition Javascript to format the table (such as making URLs clickable). And if you are creating your own HTML table, then you can put the TABLE & THEAD in the header and TFOOTER and /TABLE in the footer.

The short code builder admin page includes sections for header and footer. To do this manually, in the content section of your [cfdb-html] short code, add special delimiters to indicate the header and footer parts. See the example below:

[cfdb-html form="blogs" show="name,title,blogtext" limit="10" orderby="Submitted desc"]
{{BEFORE}}<div class="your-header-style">Registered Users:{{/BEFORE}}
<div class="your-headline-style">${name}: ${title}</div>

<div class="your-content-style">${blogtext}</div>

{{AFTER}}<div class="your-footer-style">Thanks to everyone!{{/AFTER}}
[/cfdb-html]

  1. March 21st, 2011 at 11:50 | #1

    Outstanding addition to CFDB plugin. Great work!

  2. Gillian
    May 29th, 2011 at 05:16 | #2

    Hi Michael

    I have got my HTML code working well thanks to your helpful documentation. Now I’d like to add a refinement to include an “if – then – else” statement so that a blank field does not output a blank line on my page (which looks messy). From my reading, I can put a Javascript routine inside the HTML to do this, however I cannot get it to work. On another page on my site I use the “Inline” plugin to embed Javascript with an “if – then – else” statement in the HTML but it looks like either I can’t nest the Inline shortcode inside your HTML shortcode, or my syntax has gone awry somewhere :-(. Can you offer any thoughts on how to successfully include an “if – then – else” statement or on some other way to suppress blank lines?

    Many thanks in advance

    Gillian

  3. July 7th, 2011 at 12:53 | #3

    Hi Michael,
    Thanks for the great plugin – Very good indeed!
    I’m using the filelinks option in the [cfdb-html form="myform" filelinks="img"] shortcode but all I get displayed is the image file name and not the actual image file. The code I’m using is:

    [cfdb-html "Form: 1" filelinks="img"]
    ${photo_1}
    [/cfdb-html]

    Please can you help?

    Many thanks in advance

    Damien.

  4. October 3rd, 2011 at 03:06 | #4

    Hi Michael,
    The plugin is amazing, thank you for sharing with the world! My question is this, is there any way to only show data posted in the last seven days? I don’t know how to limit the results like that.

    Thank you for your help

  5. November 14th, 2011 at 12:25 | #5

    I’m Using WP 3.2.1 and updated versions of fast secure contact forms and the db extension plugin – the [cfdb-table form="myform"] works great but none of the other options work i.e., [cfdb-html… or [cfdb-json… and so on – only the [cfdb-table… short codes work – the other codes simply don’t appear at all – blank and nothing in source code either? Please help me with this as I am attempting to post/show the img files from form on page and need to use the [cfdb-html form="myform" filelinks="img"] code…

    thank You for your plugin and time! i will gladly donate some more money if i can get an answer to this issue.

  6. Amanda Gillespie
    November 23rd, 2011 at 04:07 | #6

    Great plugin! thanks so much!

    Any idea how to get the html shortcode to work with pagination though?

    • Michael Simpson
      November 28th, 2011 at 22:51 | #7

      if you put the following in your post, you can get styles that have a next and previous button at the bottom right. But there is a problem where these button images do no display, so they are dim squares and it is not obvious what they are. I haven’t figured out the problem.

      @import “/wp-content/plugins/contact-form-7-to-database-extension/jquery-ui/jquery-ui.css”;
      @import “/wp-content/plugins/contact-form-7-to-database-extension/DataTables/media/css/demo_table.css”;

      [cfdb-datatable form="your-form" id="mytable"]

  7. Allan
    January 31st, 2012 at 16:15 | #8

    Im wondering if it’s possible to ORDER BY RAND() in the shortcode. Thanks.

    • Michael Simpson
      January 31st, 2012 at 16:35 | #9

      No, the order by does not directly pass through to MySQL. It probably should. At some point I want to upgrade this to support different kinds of sorts.

  8. pachouli
    February 21st, 2012 at 13:31 | #10

    Can you give me an example where you filter on one column and on multiple columns with boolean and regular expressions. I can’t get that option to work? Thanks!

  9. Johnny Wilson
    March 12th, 2012 at 12:14 | #12

    Great plug in, all works except when I select [cfdb-html] as shortcode I get: Error: [cfdb-html] has empty Template. It will not output anything.
    And my page shows blank results. Where is the Template or what do I do to build it and where does it go? Thanks.

    • Michael Simpson
      March 12th, 2012 at 12:16 | #13

      The template text is the stuff that goes between the open and close tag [cfdb-html] template stuff here [/cfdb-html]

  10. June 11th, 2012 at 14:20 | #14

    I am trying to get my ${Services} field to show up in a drop down list and I end up with 10 different dropdown lists with two options in each one. Is is possible to have them all in one dropdown? Here is my code…

    [cfdb-html form="Services" hide="Submitted,_wpcf7,_wpcf7_version,_wpcf7_unit_tag,_wpnonce,_wpcf7_is_ajax_call,Submitted Login,Submitted From,submit_time"]Any${Services}[/cfdb-html]
    Search

  11. Maulik
    August 19th, 2012 at 02:53 | #15

    Hello Michael,

    Thanks a ton for such a Unique and Utility plugin…

    I am using “cfdb-html” to display matrimonial member profile… Is there a way we can achieve below mentioned functionality?

    1) Pagination to show more listing than “limit” number for “cfdb-html” ?
    2) Can I hyperlink any basic listing “${value}” to display full profile of the same record on another page? What should be URL Parameter?
    3) Is there a way to calculate “Current Age” based on Birth Date entered using DatePicker by user?
    4) I am also looking for advanced search functionality to search with multiple criteria.

    I will really appreciate if you can please help me for above mentioned points.

    • Michael Simpson
      August 26th, 2012 at 10:05 | #16

      1) The plugin doesn’t do pagination nicely. But if you use cfdb-datatable, you can let the datatable do pagination for you. All the table results are actually downloaded to the page, and the datatable allows you to paginate over that (as opposed to pulling a page at-a-time from the server.

      2) Yes (if I understand correctly). In a cfdb-html short code, you could construct a URL to another page or post with that ${value} as a GET parameter in the URL. Then you put a short code on that target page that uses Filter Variable Substitution to apply that GET parameter in the short code “filter”.

      3) UI widgets on your form are outside the scope of this plugin. But I figure you could use a jQuery UI Date Picker and add some custom javascript code to accomplish this.

      4) This post might be useful: Creating a form to search the database

  12. Maulik
    August 27th, 2012 at 08:29 | #17

    Oh Wow… Thanks so much for your guidance… I will look in to this options further.

  13. Amanda Gillespie
    October 16th, 2012 at 05:53 | #18

    Any way to combine tables? Use case is: A conference website with separate forms for registration and abstract submission. I have manually updated the database using the submit_time of registration as a primary key in abstract submission (ie, for this abstract, has the person registered?). I am trying to create a sort of mail-merge form for myself for confirmation of details, and I want to be able to say Dear (first) (last), you have registered with these details (from form 1) and this abstract (form 2).

  14. Michael Simpson
    October 21st, 2012 at 12:01 | #19

    @Amanda Gillespie
    Not really a way to do a table join. I think you would have to write some custom SQL to pull that off.

  15. Peter
    November 18th, 2012 at 18:23 | #20

    In http://wordpress.stackexchange.com/questions/45266/how-to-use-other-shortcodes-inside-contact-form-7-forms I found how to make cfdb shortcodes work in Contact Form 7 forms, but they don’t seem to work in the e-mails it sends. Anyone knows how to get that working too?
    Thanks….

  16. saj
    April 17th, 2013 at 03:01 | #21

    I want to display the form data between 2 dates (those 2 dates should get from the same page) .. Please help me how to work on it..

  17. Isidoros
    May 9th, 2013 at 14:53 | #23

    @Gillian
    Hello Gillian I know its a bit long time ago but can you give me a hint how did you work out with this issue because I am facing it now.
    Thank you in advance!

    • Michael Simpson
      May 9th, 2013 at 15:17 | #24

      On the if-them-else issue, right now it is not supported in cfdb-html. You have to Create Your Own Short Code. There is an example on that page of doing an “if” check.

  18. mshafshak
    December 26th, 2013 at 02:46 | #25

    i have to fields 1 for uploading image and one for uploading a video, i made the filelinks=”img” how can i make the video field shows as a link ? please help me
    thank u

    • Michael Simpson
      December 26th, 2013 at 08:13 | #26

      Using filelinks=”img” will assume all links are images and insert an IMG tag. For a mix, use filelinks=”url” and in the HTML template, write out your IMG tag and whatever you want the HTML too look like for the video URL.

  19. cl0ust3r
    August 30th, 2014 at 16:20 | #27

    Hi

    I have a date field format Y-m-d no way to change the format d-m-Y ¿?

    Thank

    • Michael Simpson
      August 30th, 2014 at 19:09 | #28

      For a field “mydate” in your form, try adding to the short code: trans="tmp=strtotime(mydate)&&mydate=date('d-m-Y',tmp)"

  20. ginatto
    September 29th, 2014 at 13:13 | #29

    @Michael Simpson
    How can I re-dimension a image?

    • Michael Simpson
      September 29th, 2014 at 15:13 | #30

      Use filelinks=”url” and in the template create the image tag like img src=”${image-field} width=”100″ height=”100″

  21. ginatto
    September 29th, 2014 at 16:02 | #31

    @Michael Simpson

    Hi, dosen’t work, I try do:

    [cfdb-html form="MyForm" show="your-name,your-img" filelinks="url"]

    ${your-name}

    [/cfdb-html]

    How I must do exactly?

  22. ginatto
    September 29th, 2014 at 16:05 | #32

    sorry the line was vanish.

    Hi, dosen’t work, I try do:

    [cfdb-html form="MyForm" show="your-name,your-img" filelinks="url"]

    img src=”${your-img}” width=”100″ height=”100″ -> input “”
    ${your-name}

    [/cfdb-html]
    How I must do exactly?

    • Michael Simpson
      September 29th, 2014 at 16:06 | #33

      [cfdb-html form="MyForm" show="your-name,your-img" filelinks="url"]
      ${your-name} <img src="${your-img}" height="100" width="100"/>
      [/cfdb-html]

  23. ginatto
    September 29th, 2014 at 16:16 | #34

    I try like you show. But when I view the post show the text not image:

  24. ginatto
    September 29th, 2014 at 16:17 | #35

    @Michael Simpson
    I try like you show. But when I view the post show the text not image:
    img src=”http://www.sudbr.org/wp-admin/admin-ajax.php?action=cfdb-file&s=1411507578.8409&form=qust-mormon-politicos-2014&field=img-camp”height=”100″ width=”100″

  25. ginatto
    September 29th, 2014 at 16:31 | #36

    Thanks, I did. I was edit the code on visual post, when I should edit on text.

Comments are closed.  Go To Support Forum