Skip to:
Content
Pages
Categories
Search
Top
Bottom

Is it possible to have two post forms in one page?

  • OK. I know it sounds crazy and pointless, but let me explain myself… I am using the buddypress-sliding-login-panel plugin (http://buddypress.org/community/groups/buddypress-sliding-login-panel/) and I want to insert a mini post form in the sliding panel, so the members can quickly update their activity without having to go to the activity/profile/groups page. Just take a look at the screenshot to get the general idea: http://awesomescreenshot.com/03fox371

    The form had to be smaller, so I just copied the post-form.php (in bp-themes/bp-default/activity) and I created a new file named post-form-mini.php and I simply changed the dimensions of the post box.

    So far so good… But here comes the problem!

    If I change the ids and names of the form and/or the textarea the mini post form doesn’t work at all.
    If I simply keep the same ids and names as in the main post form (

    ,
Viewing 5 replies - 1 through 5 (of 5 total)
  • Any ideas? I :-/


    Anointed
    Participant

    @anointed

    somewhat related:
    http://farinspace.com/multiple-wordpress-wysiwyg-visual-editors/

    Wish I could help with the actual visual editor you are working with, but alas no experience doing that, just happened upon the article above yesterday while working on another project. Hope it lends some ideas

    @anointed Thanks for the link. The post looks interesting but, unfortunately, I don’t think it’s useful in my case. Thanks anyway :)

    This thing is driving me crazy! Do you think I could solve the problem by altering the code of the post button?

    <input type="submit" name="aw-whats-new-submit" id="aw-whats-new-submit" value="” />

    I think I solved it!!! Here’s how, in case anybody else wants to do something similar:

    Step 1: edit “wp-content/plugins/buddypress/bp-themes/bp-default/_inc/global.js”

    Step 2: Go to line #35 (/* New posts */) and simply copy and paste the the new posts section right after it (line #102)

    Step 3: Change every single value that refers to ids of the original form (e.g. change #aw-whats-new-submit to #mini-aw-whats-new-submit)

    Step 4: Go to the mini-post code on your template and replace the ids. Obviously you have to use the same ids as the ones you created on Step 3

    To make a long story long, here’s my code:
    global.js


    /* MINI-POST */
    /* New posts */
    jq(“input#mini-aw-whats-new-submit”).click( function() {
    var button = jq(this);
    var form = button.parent().parent().parent().parent();

    form.children().each( function() {
    if ( jq.nodeName(this, “textarea”) || jq.nodeName(this, “input”) )
    jq(this).attr( ‘disabled’, ‘disabled’ );
    });

    jq( ‘form#’ + form.attr(‘id’) + ‘ span.ajax-loader’ ).show();

    /* Remove any errors */
    jq(‘div.error’).remove();
    button.attr(‘disabled’,’disabled’);

    /* Default POST values */
    var object = ”;
    var item_id = jq(“#mini-whats-new-post-in”).val();
    var content = jq(“textarea#mini-whats-new”).val();

    /* Set object for non-profile posts */
    if ( item_id > 0 ) {
    object = jq(“#mini-whats-new-post-object”).val();
    }

    jq.post( ajaxurl, {
    action: ‘post_update’,
    ‘cookie’: encodeURIComponent(document.cookie),
    ‘_wpnonce_post_update’: jq(“input#_wpnonce_post_update”).val(),
    ‘content’: content,
    ‘object’: object,
    ‘item_id’: item_id
    },
    function(response)
    {
    jq( ‘form#’ + form.attr(‘id’) + ‘ span.ajax-loader’ ).hide();

    form.children().each( function() {
    if ( jq.nodeName(this, “textarea”) || jq.nodeName(this, “input”) )
    jq(this).attr( ‘disabled’, ” );
    });

    /* Check for errors and append if found. */
    if ( response[0] + response[1] == ‘-1’ ) {
    form.prepend( response.substr( 2, response.length ) );
    jq( ‘form#’ + form.attr(‘id’) + ‘ div.error’).hide().fadeIn( 200 );
    button.attr(“disabled”, ”);
    } else {
    if ( 0 == jq(“ul.activity-list”).length ) {
    jq(“div.error”).slideUp(100).remove();
    jq(“div#message”).slideUp(100).remove();
    jq(“div.activity”).append( ‘

      ‘ );
      }

      jq(“ul.activity-list”).prepend(response);
      jq(“ul.activity-list li:first”).addClass(‘new-update’);
      jq(“li.new-update”).hide().slideDown( 300 );
      jq(“li.new-update”).removeClass( ‘new-update’ );
      jq(“textarea#mini-whats-new”).val(”);

      /* Re-enable the submit button after 8 seconds. */
      setTimeout( function() { button.attr(“disabled”, ”); }, 8000 );
      }
      });

      return false;
      });
      /* MINI-POST */

      and the form for the new “mini-post-form”


      <form action=”<?php bp_activity_post_form_action() ?>” method=”post” id=”mini-whats-new-form” name=”mini-whats-new-form”>

      <?php do_action( ‘bp_before_activity_post_form’ ) ?>

      <textarea name=”mini-whats-new” onFocus=”this.value=”; this.onfocus=null;” id=”mini-whats-new” rows=”2″ cols=”40″>Got something to share?</textarea>

      <div id=”whats-new-submit”>

      <span></span>

      <input type=”submit” name=”mini-aw-whats-new-submit” id=”mini-aw-whats-new-submit” value=”<?php _e( ‘Post’, ‘buddypress’ ) ?>” />

      </div>

      <div id=”whats-new-post-in-box”>

      <?php _e( ‘Post in’, ‘buddypress’ ) ?>:

      <select id=”mini-whats-new-post-in” name=”mini-whats-new-post-in”>

      <option selected=”selected” value=”0″><?php _e( ‘My Profile’, ‘buddypress’ ) ?></option>

      <?php if ( bp_has_groups( ‘user_id=’ . bp_loggedin_user_id() . ‘&type=alphabetical&max=100&per_page=100&populate_extras=0’ ) ) : while ( bp_groups() ) : bp_the_group(); ?>

      <option value=”<?php bp_group_id() ?>”><?php bp_group_name() ?></option>

      <?php endwhile; endif; ?>

      </select>

      </div>

      <input type=”hidden” id=”mini-whats-new-post-object” name=”mini-whats-new-post-object” value=”groups” />

      <?php do_action( ‘bp_activity_post_form_options’ ) ?>

      <?php wp_nonce_field( ‘post_update’, ‘_wpnonce_post_update’ ); ?>

      <?php do_action( ‘bp_after_activity_post_form’ ) ?>

      </form><!– #mini-whats-new-form –>

      <form action=”<?php bp_activity_post_form_action() ?>” method=”post” id=”mini-whats-new-form” name=”mini-whats-new-form”>
      <?php do_action( ‘bp_before_activity_post_form’ ) ?>
      <textarea name=”mini-whats-new” onFocus=”this.value=”; this.onfocus=null;” id=”mini-whats-new” rows=”2″ cols=”40″>Got something to share?</textarea> <div id=”whats-new-submit”> <span></span>   <input type=”submit” name=”mini-aw-whats-new-submit” id=”mini-aw-whats-new-submit” value=”<?php _e( ‘Post’, ‘buddypress’ ) ?>” /> </div>
      <div id=”whats-new-post-in-box”> <?php _e( ‘Post in’, ‘buddypress’ ) ?>:
      <select id=”mini-whats-new-post-in” name=”mini-whats-new-post-in”> <option selected=”selected” value=”0″><?php _e( ‘My Profile’, ‘buddypress’ ) ?></option>
      <?php if ( bp_has_groups( ‘user_id=’ . bp_loggedin_user_id() . ‘&type=alphabetical&max=100&per_page=100&populate_extras=0’ ) ) : while ( bp_groups() ) : bp_the_group(); ?> <option value=”<?php bp_group_id() ?>”><?php bp_group_name() ?></option> <?php endwhile; endif; ?> </select> </div> <input type=”hidden” id=”mini-whats-new-post-object” name=”mini-whats-new-post-object” value=”groups” />

      <?php do_action( ‘bp_activity_post_form_options’ ) ?>
      <?php wp_nonce_field( ‘post_update’, ‘_wpnonce_post_update’ ); ?> <?php do_action( ‘bp_after_activity_post_form’ ) ?>
      </form><!– #mini-whats-new-form –>


    noizeburger
    Participant

    @noizeburger

    Is this still working? What I’m trying to do is put the What’s-New-Form into my sidebar.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Is it possible to have two post forms in one page?’ is closed to new replies.
Skip to toolbar