Forums

[Plugin: Fast and Secure Contact Form] Putting form in text widget in sidebar (15 posts)

  1. securemedicaresolutions
    Member
    Posted 2 years ago #

    Is it possible to do this? I have not been able to figure out how. I am trying to figure out how to get this form in a sidebar as a static element on a non-static page. Ideas?

    http://wordpress.org/extend/plugins/si-contact-form/

  2. Mike Challis
    Member
    Posted 2 years ago #

    How can I add the contact form to a template manually rather than use
    shortcode in a page?

    Manually:
    Use this code: <?php if ( isset($si_contact_form) ) echo
    $si_contact_form->si_contact_form_short_code( array( 'form' => '1' )
    ); ?>

    Shortcode in a sidebar: this tells how ...
    http://englishmike.net/2008/07/07/wordpress-quick-tips-3adding-a-shortcode-to-a-sidebar-widget/

  3. leonardof
    Member
    Posted 2 years ago #

    Mike, I couldn't get this working. The regular text widget obviously just spit the code, character by character, so I went with the PHP Code widget. But it doesn't show anything; if I remove the if clause, it prints an error message: Fatal error: Call to a member function si_contact_form_short_code() on a non-object in /home/leonardof/leonardof.med.br/wp-content/plugins/php-code-widget/execphp.php(43) : eval()'d code on line 2

  4. Mike Challis
    Member
    Posted 2 years ago #

    Did you try the method from the link I posted?

    Do you want to be able to use a shortcode in your blog’s sidebar instead of your post or page?

    Normally, shortcodes are ignored if you try putting them in a sidebar widget — all that’s displayed is the shortcode itself. But there is a one-line tweak you can add to your theme that will enable you to put any shortcode you like in a sidebar widget. For example, one AZIndex user recently wanted to display an index generated by the plugin in his blog’s sidebar. These are the steps he followed:

    1. Login to your blog’s administration pages and go to the Theme Editor — i.e. select Design >> Theme Editor from the admin menu.
    2. Look in the list of Template Files on the right of the page for one called Theme Functions or functions.php and click on it to load it into the editor.
    3. Find a place between the <?php and ?> tags which is not in the middle one of the functions that may already be in the file (the very top or bottom of the file are both good places) and add the following line:
    add_filter('widget_text', 'do_shortcode');
    4. Click on the Update File button to save the modified template.

    That’s all you need to do. Now any shortcodes you add to a sidebar widget will be correctly processed by the plugin they belong to. The easiest way to test this is as follows:

    1. Go to Design >> Widgets using the administration menu.
    2. Find the Text widget in the list on the left, and click its Add button.
    3. Click on the new widget’s Edit link, and enter a title for the widget and then add the shortcode below it.
    4. Click the Change button, then click the Save Changes button (easy to forget) and then go to the front page of your blog to see your new shortcode-enabled widget.

    (Note: your theme must support widgets for the new text widget to show up. If it doesn’t then you will have to “widgetize” your theme or find another theme that does support widgets.)

    So if you have been itching to use AZIndex to put an index of posts in your sidebar (just not too big, I hope) then now you know how to do it! Of course, this tip will work for any plugin that uses shortcodes.

  5. ericthelion
    Member
    Posted 2 years ago #

    Woo Hoo!
    Thanks Mike - great support, and great plugin.

  6. sjmills93
    Member
    Posted 1 year ago #

    Hi Mike

    I've tried both methods and cannot get it to work. Website: http://www.ellarebanks.ca. Using WordPress 2.9.2 and wedget ready theme (modified for client).

    Here's my functions.php file:

    <?php
    add_filter('widget_text', 'do_shortcode');

    // Widgets
    if(function_exists('register_sidebar')) {
    register_sidebar(array(
    'name' => __('Sidebar'),

    'before_widget' => '<li id="%1$s" class="widget %2$s">',
    'after_widget' => '',
    'before_title' => '<h3>',
    'after_title' => '</h3>',

    ));
    }
    ?>

    Here's the code I entered from my sidebar.php file:

    <!-- Fast and Secure Contact Form plugin begin -->
    <div style="width:255px;margin-left:15px;margin-right:10px;border:0;color:#ffffff;">
    [si-contact-form form='2']

    </div>
    <!-- Fast and Secure Contact Form plugin end -->

    What am I missing?

  7. Mike Challis
    Member
    Posted 1 year ago #

    sjmills93,

    Try this, take out the shortcode and replace with this PHP code in the very same place

    if ( isset($si_contact_form) ) echo
    $si_contact_form->si_contact_form_short_code( array( 'form' => '2' ) );

    Does that work?

  8. sjmills93
    Member
    Posted 1 year ago #

    Mike

    Sadly no this does not work.

  9. Mike Challis
    Member
    Posted 1 year ago #

    Try it like this with PHP tags:

    <?php
    if ( isset($si_contact_form) ) echo
    $si_contact_form->si_contact_form_short_code( array( 'form' => '2' ) );
    ?>
  10. sjmills93
    Member
    Posted 1 year ago #

    Hmmm.....now the code at least does not display on the published page, but neither do the input fields (there are two - one for name and the other for email address).

    But I think we're getting closer....

  11. sjmills93
    Member
    Posted 1 year ago #

    Also, the WordPress theme I used as a base is MagicBlue, although I've edited colours and font types

  12. Mike Challis
    Member
    Posted 1 year ago #

    what if you temporarily switch to the default theme, does it work?

  13. sjmills93
    Member
    Posted 1 year ago #

    Mike

    That didn't work either. I used the last PHP code you gave me between the PHP tags.

    See a screen print in the MagicBlue theme.
    http://www.ellarebanks.ca/screenprint_contactform.pdf

  14. sjmills93
    Member
    Posted 1 year ago #

    The weird thing is that I'm seeing the Stay Informed title in the sidebar with the short code, which is being displayed as a result of the Widget noted above (i.e."add_filter" etc)

  15. sjmills93
    Member
    Posted 1 year ago #

    I note on the Tips page noted above that one of the responses to this tip from Bullion" stated the following:

    To use your shortcodes outside of posts, pages, and the text widget, you could always call your shortcode function directly like this:

    $text = yourShortCodeFunction(‘[your shortcode tag here]‘);
    echo $text;

    The above code will allow you to use wordpress shortcodes anywhere in your blog. Keep up the good work.

    However, I do not know enough about this syntax to figure out how I would adjust it for the contact form. I get where I'd put the short code but what would I put for "yourShortCodeFunction" and I'm assuming this would be pasted directly into the Sidebar.php file

Topic Closed

This topic has been closed to new replies.

About this Topic