WordPress.org

Ready to get started?Download WordPress

Forums

Limit Posts to 140 Characters (18 posts)

  1. Scotm
    Member
    Posted 4 years ago #

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

    Thx

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

  3. Scotm
    Member
    Posted 4 years 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 4 years 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 4 years 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 4 years ago #

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

  7. jmunn
    Member
    Posted 4 years 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 4 years 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 4 years 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 4 years 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 4 years ago #

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

  12. dlopeman
    Member
    Posted 4 years 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 4 years 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;
     }
    }
  14. oqm4
    Member
    Posted 4 years ago #

    I've got the exact same challenge as jmunn: I've set up a nicely working system for limiting characters in the original post but can't seem to make things work when editing inline.

    I tried dlopeman's method above to no avail.

  15. howardshippin
    Member
    Posted 4 years ago #

    A related problem is that if we want to link WP to Twitter, using Publicize, the message truncates by default not at 140 characters, but at around 70, adding a link to the WP blog. It's not possible to say anything useful in that number of characters, and not polite to send someone back to WordPress for an unfinished sentence. Of course, it's possible to edit the way Publicize sends to Twitter on the Dashboard (and there is a character counter there). But this makes the P2 editing box redundant. So part of P2's functionality is currently unusable for anyone who wants to link to Twitter.

  16. jmunn
    Member
    Posted 4 years ago #

    I never made any ground on this oqm4. If I do I'll try to post up.

  17. acousins
    Member
    Posted 4 years ago #

    its unfortunate there's not a "notification" option for responses on threads.. =)

    @jmunn I personally haven't a way to limit "inline edits". Logically, I would think that applying the same JavaScript to the inline edit form field would work. Of course you'll need to change the id names.

    <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>
  18. Chris_K
    Member
    Posted 4 years ago #

    @acousins - subscribe to the thread with an RSS/Feed reader :-)

    http://wordpress.org/support/rss/topic/316769

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags