Forums

Limit Posts to 140 Characters (13 posts)

  1. scotm
    Member
    Posted 1 month ago #

    Does anyone have a solution to keep posts in P2 to 140 characters as per Twitter?

    Thx

  2. songdogtech
    Member
    Posted 1 month ago #

    P2 uses textarea for the comment form; try using this jQuery plugin to work with limiting input with textarea.

  3. scotm
    Member
    Posted 1 month ago #

    I believe I may have stumbled across that plugin before and moved on, but I'll look into it further.

    Thx

  4. acousins
    Member
    Posted 1 month ago #

    I use this simple bit of javascript to handle the character count

    function limitText(limitField, limitCount, limitNum) {
    	if (limitField.value.length > limitNum) {
    		limitField.value = limitField.value.substring(0, limitNum);
    	} else {
    		limitCount.value = limitNum - limitField.value.length;
    	}
    }

    I add this bet to the text area (change the 250 to desired number

    name="limitedtextarea" onKeyDown= "limitText(this.form.limitedtextarea,this.form.countdown,250);"             onKeyUp="limitText(this.form.limitedtextarea,this.form.countdown,250);"

    Then add this part for the character count number

    <input readonly type="text" name="countdown" size="3" value="250" id="numbCount">
  5. dlopeman
    Member
    Posted 3 weeks ago #

    acousins! That's probably the exact code I used!! I just did a google search and found it.

    There's no plugin, being that P2 is unique... posting from the front page isn't exactly normal... in fact, I only know of one other plugin that simulates this posting from the front page: http://wordpress.org/extend/plugins/post-from-site/ by Kelly Dawn.

  6. acousins
    Member
    Posted 3 weeks ago #

    dlopeman..we prob are as I googled this solution myself (no sense reinventing the wheel)

  7. jmunn
    Member
    Posted 2 weeks ago #

    Acousins and Dlopeman. Any chance you could help me out and describe a bit more where exactly this code goes? It seems like a great add on to P2. Thanks.

  8. jmunn
    Member
    Posted 1 week ago #

    Oops got it. Had to rename the textarea to "limitedtextarea" all together which I didn't get at first. Thanks guys.

  9. jmunn
    Member
    Posted 1 week ago #

    Actually, I limited the comments the same way but cannot figure out how to limit the inline edits as well. Any ideas?

  10. dlopeman
    Member
    Posted 1 week ago #

    Hmmm - good point! I do the same limit on the Original post... but not inlines! Thanks for making me think! LOL

  11. jmunn
    Member
    Posted 1 week ago #

    My pleasure dlopeman. :-) If you get anywhere with your thinking let us know cause I'm at a loss.

  12. dlopeman
    Member
    Posted 1 week ago #

    Part of my problem is this... well... lemme explain...

    People post pictures or videos
    They enter a Title
    They enter a brief (256 characters - call me a geek) description

    But the picture insertion is kinda automated... You choose your picture to upload, and it uploads is "inline" - then you can hit "Use it" button which puts the appropriate code into the TEXTAREA. WEll, THAT uses characters and right then the user is limited to less than 256.

    So... the trick will be to somehow not count the whole <img....> tag...

    Ideas?

    I really would have preferred a separate field, but have not played the the wordpress meta crap... if that's even how to do it...

    I was able to get the TITLE working, b/c it looks like P2 may have had it at one time and there was still bits of code in functions.php and p2.js for it... I just re-enabled them sort of...

  13. dlopeman
    Member
    Posted 1 week ago #

    OH, for you jmunn (I'm assuming you have some knowledge a html/php) If not... then get-on-it!! LOL

    Anyway - this probably REPEATS what acousins already put up there...

    Here's what you put in post-form.php in the place of the textarea:

    <textarea name="posttext" id="posttext" rows="4" style="padding:3px; width:438px;" onKeyDown="limitText(this.form.posttext,this.form.countdown,256);" onKeyUp="limitText(this.form.posttext,this.form.countdown,256);" /></textarea>
    
    <font size="1">Characters left (max 256): <input readonly type="text" name="countdown" size="3" value="256" style="border:0px; margin-top:5px"></font>

    and then in a Javascript <script></script> or maybe in inc/j2.inc (which will get overwritten on upgrades) or I made a new JS called inc/my-functions.js... just remember to call it in header.php

    function limitText(limitField, limitCount, limitNum) {
            if (limitField.value.length > limitNum) {
                    limitField.value = limitField.value.substring(0, limitNum);
            } else {
                    limitCount.value = limitNum - limitField.value.length;
     }
    }

Reply

You must log in to post.

About this Topic

Tags