Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    JComments component    Suggestions, Wishlists & Feature Requests    Topic: Limit number of empty lines / linebreaks
Pages: [1]   Go Down
  Print  
Author Topic: Limit number of empty lines / linebreaks  (Read 5976 times)
0 Members and 1 Guest are viewing this topic.
Balance
Newbie
*

Karma: 0
Offline Offline

Posts: 2


« on: October 27, 2010, 06:57:06 »

I just tried to find a few ways in which unregistered users could mess up the comment section and one thing that came to mind was long, empty comments.

I tried it out and sure enough it worked: As you know you can set the limit of characters for unregistered users to whatever you want, say 1000 - but if unregistered users press and hold the Enter key then you end up with a looooong, empty comment.

Is there a way to limit the ammount of linebreaks (that is <br />) to 2 or 3 in a row?
If so I think it might be a valuable addition to the next version. Or perhaps someone even knows a quick-fix for this problem that can be implemented immediately? Youtube does it as well for example.

Thanks.
Logged
smart
Administrator
Hero Member
*****

Karma: 188
Offline Offline

Gender: Male
Posts: 1883



WWW
« Reply #1 on: October 27, 2010, 14:19:22 »

You could implement this via Custom BBCode feature:

This is quite easy.

1. Open Custom BBCode manager
2. Press Add button
3. Enter 'Strip blank lines' to the name field
4. Swith to Advanced regular expression in Pattern section and enter regexp:
Code:
(<br \/>)?(<br \/>){2,}
5. Switch to Advanced (Regular Expression) in Replacement (HTML) section and enter:
Code:
${1}<br />
6. Switch to Advanced (Regular Expression) in Replacement (Text) section and enter:
Code:
${1}<br />
7. Set Publishing to Yes
8. Set permissions for each usergroup
9. Press Save button

After this all sequencies of empty lines longer than 2 empty lines would be removed.
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
Balance
Newbie
*

Karma: 0
Offline Offline

Posts: 2


« Reply #2 on: October 28, 2010, 08:06:56 »

Hi smart!

Thank you again for your fast solution.
Unfortunately it doesn't seem to work, perhaps there is some error in those codes or something you forgot to tell us?



EDIT: AH! I'm sorry. When I tried this on my local XAMPP website, I didn't realize that unlike my live website it still had "customBBcode" disabled. You obviously have to set "Enable customBBcode" to Yes under "Layout" for this to work.

Works perfectly now, thanks!
« Last Edit: October 28, 2010, 08:18:25 by Balance » Logged
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Suggestions, Wishlists & Feature Requests    Topic: Limit number of empty lines / linebreaks
 
Jump to: