Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    No, but good point. That goes on the to do list.

    Thread Starter Recon

    (@recon)

    Do you have an idea as to when this will be available?

    This is a great plugin and, for my needs, this is the only missing feature.

    Thanks for all the help so far.

    Plugin Author Michael Simpson

    (@msimpson)

    I don’t know. But you may be able to accomplish what you want using the technique described in the new Create Your Own Short Code page

    Thread Starter Recon

    (@recon)

    Thanks for the link. I think that I could figure out how to make a custom shortcode to display a value only if the value exists in the db, but how could I use this inside a regular [cfdb-html] shortcode?

    Would I need to recreate the entire [cfdb-html] shortcode to achieve this? Using a shortcode within a shortcode wouldn’t work, right?

    Plugin Author Michael Simpson

    (@msimpson)

    You would not use [cfdb-html], you would use the shortcode you create and do a similar thing in it. Try this:

    require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
    $exp = new CFDBFormIterator();
    $exp->export($atts['form'], $atts);
    while ($row = $exp->nextRow()) {
       echo '<h2>' . $row['name'] . '</h2>';
       echo '<p>' .  $row['bio'] . '</p>';
       if ($row['url'] != null {
          echo '<p><a href="' . $row['url'] . '">Website</a></p>';
       }
    }

    I apologize for hijacking this thread but has anyone a solution to be able to send attachments to a permanent directory on the server?

    I have to have attachments made available for retrieval via FTP from a directory.

    FYI I have adapted a mod to the root .htaccess file that allows for larger files to be uploaded, to defeat these files going into email I would leave the short codes out of the form.

    Suggestions?

    @mrjak01: It is considered impolite to interrupt another poster’s thread. Please post a new topic.

    Thread Starter Recon

    (@recon)

    Great, thanks Michael! That works great ??

    I have one more question. When using the [cfdb-html] shortcode, fields containing line breaks were displayed correctly. This was fixed when you introduced the wpautop option.

    With my own shortcode, this no longer works. I tried adding wpautop="true" and wpautop="false" but neither worked. How can I re-enable this with my own shortcode?

    Thread Starter Recon

    (@recon)

    Actually, it wasn’t the wpautop option that fixed this problem with the [cfdb-html] shortcode. I believe it was a separate fix. Hopefully the same fix for custom shortcodes isn’t too difficult to add.

    Thanks again!

    Plugin Author Michael Simpson

    (@msimpson)

    The wpautop option is for [cfdb-html] only. If you create your own shortcode, that option is ignored unless you write code to do something with it.

    The WP autop thing has been a pain because I can’t seem to find an API to selectively turn it off. By the time [cfdb-html] gets the content, WP has already injected P and BR tags. So my code has a hack to try to identify the pattern and strip those tags out. You could try something similar in the PHP of your own custom short code. Look at the file ExportToHtmlTemplate.php and search for if (!$wpautop) and you will find the code block that does that.

    Thread Starter Recon

    (@recon)

    Reading your previous post again, I don’t think this problem is related to wpautop.

    I am looking to preserve line breaks within a field, not between different outputted fields. It looks like the relevant code starts on line 152 in ExportToHtmlTemplate.php. Is it possible to include this in a custom shortcode like the one above?

    Plugin Author Michael Simpson

    (@msimpson)

    OK, I see what you are referring to. That is replacing line breaks in the field text with HTML new lines. You should be able to include that in custom short code PHP. Actually, using the nl2br function would easier, something like:

    require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
    $exp = new CFDBFormIterator();
    $exp->export($atts['form'], $atts);
    while ($row = $exp->nextRow()) {
        $row['name'] = nl2br($row['name']);
        echo $row['name'];
    }
    Thread Starter Recon

    (@recon)

    Fantastic. Thanks for quick reply.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Plugin: Contact Form 7 to Database Extension] IF statement with [cfdb-html] shortcode’ is closed to new replies.