Adding The Wire plugin form to the Riverdashboard plugin

So you want to have The Wire plugin form in Riverdashboard plugin eh? Well it's really simple! Follow the steps below.

Copy this code:

<div class="post_to_wire">
<h3><?php echo elgg_echo("thewire:doing"); ?></h3>
<script>
function textCounter(field,cntfield,maxlimit) {
    // if too long...trim it!
    if (field.value.length > maxlimit) {
        field.value = field.value.substring(0, maxlimit);
    } else {
        // otherwise, update 'characters left' counter
        cntfield.value = maxlimit - field.value.length;
    }
}
</script>

        <form action="<?php echo $vars['url']; ?>action/thewire/add" method="post" name="noteForm">
                        <?php
                            $display .= "<textarea name='note' value='' onKeyDown=\"textCounter(document.noteForm.note,document.noteForm.remLen1,140)\" onKeyUp=\"textCounter(document.noteForm.note,document.noteForm.remLen1,140)\" id=\"thewire_large-textarea\">{$msg}</textarea>";
                $display .= "<div class='thewire_characters_remaining'><input readonly type=\"text\" name=\"remLen1\" size=\"3\" maxlength=\"3\" value=\"140\" class=\"thewire_characters_remaining_field\">";
                echo $display;
                echo elgg_echo("thewire:charleft") . "</div>";
                                echo elgg_view('input/securitytoken');
                        ?>
                        <input type="hidden" name="method" value="site" />
                        <input type="submit" value="<?php echo elgg_echo('save'); ?>" />
        </form>
</div>
<?php echo elgg_view('input/urlshortener'); ?>

and open /mod/riverdashboard/views/default/riverdashboard/welcome.php - once you open that, then paste the code above, below this piece of code:

<div id="content_area_user_title">
        <h2><?php echo sprintf(elgg_echo('welcome:user'), $name); ?></h2>
</div>

and that's it! See a working demo at my site at demyx.com.

  • thanks for the tip!

    for elgg 1.7.7 the code has to be slightly modified. here's my complete "welcome.php":

    <?php

     

    /**

     * Elgg Riverdashboard welcome message

     * 

     * @package ElggRiverDash

     * 

     */

     

    $name = '';

    if (isloggedin()) {

    $name = get_loggedin_user()->name;

    }

     

    ?>

    <div id="content_area_user_title">

    <h2><?php echo sprintf(elgg_echo('welcome:user'), $name); ?></h2>

    </div>

     

    <!-- Wire Input Form added -->

    <div class="post_to_wire">

    <h3><?php echo elgg_echo("thewire:doing"); ?></h3>

    <script>

    function textCounter(field,cntfield,maxlimit) {

        // if too long...trim it!

        if (field.value.length > maxlimit) {

            field.value = field.value.substring(0, maxlimit);

        } else {

            // otherwise, update 'characters left' counter

            cntfield.value = maxlimit - field.value.length;

        }

    }

    </script>

            <form action="<?php echo $vars['url']; ?>action/thewire/add" method="post" name="wireForm">

                            <?php

                                $display .= "<textarea name='body' value='' onKeyDown=\"textCounter(document.noteForm.note,document.noteForm.remLen1,140)\" onKeyUp=\"textCounter(document.noteForm.note,document.noteForm.remLen1,140)\" id=\"thewire_large-textarea\">{$msg}</textarea>";

                    $display .= "<div class='thewire_characters_remaining'><input readonly type=\"text\" name=\"remLen1\" size=\"3\" maxlength=\"3\" value=\"140\" class=\"thewire_characters_remaining_field\">";

                    echo $display;

                    echo elgg_echo("thewire:charleft") . "</div>";

     

                    echo elgg_view('input/securitytoken');

                            ?>

                            <input type="hidden" name="method" value="site" />

                            <input type="submit" value="<?php echo elgg_echo('save'); ?>" />

            </form>

    </div>

    <?php echo elgg_view('input/urlshortener'); ?>

  • otherwise one gets alway the following error:

    Sorry; you need to actually put something in the textbox before we can save it.