Extra nl2br's in Guestbook

Discussion corner for Developers of Serendipity.
Post Reply
bdconnolly
Regular
Posts: 140
Joined: Tue Apr 04, 2006 9:37 pm

Extra nl2br's in Guestbook

Post by bdconnolly »

I am using the Guestbook to design an online confessional. See http://www.xxxx.com/index.php?serendipi ... onfessions .

PROBLEM: posters are getting an extra line break.

SITUATION:

1. Anyway, the event_plugin can be configured to add a line break after x many letters. I don't really want that so I have it set at 20000.

2. I've got Markup: NL2BR plugin installed and working with comments (absolutely essential that this remain.)

3. I believe that the problem is in the first line of code that follows

Code: Select all

                $entry = array('comment' => wordwrap(nl2br(htmlspecialchars($row['shout'])), $wordwrap, "\n", 1));

                serendipity_plugin_api::hook_event('frontend_display', $entry);

                echo $entry['comment'];
Suggestions?
Last edited by bdconnolly on Fri Sep 15, 2006 2:12 am, edited 1 time in total.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

You're running an older version of PHP; nl2br() is giving you <br> instead of <br />. Might be a problem, but probably not. Just something I noticed.

Is it possible that you've got two copies of the nl2br plugin?

The code looks fine to me. Verify you've got the latest nl2br plugin running on Serendipity 1.0, and if that doesn't help, add the following debugging statement just before the first line:

Code: Select all

print_r $row['shout'];
This will add junk to the page. If this is unacceptable, try the following instead:

Code: Select all

error_log($row['shout'], 3, 'template_c/nl2br.log');
And report what shows up in the file.

I'm sure it's fixable. We just have to figure out what the problem is first.
Judebert
---
Website | Wishlist | PayPal
bdconnolly
Regular
Posts: 140
Joined: Tue Apr 04, 2006 9:37 pm

Post by bdconnolly »

First, I was running an older version of the nl2br plugin. We are now at 1.4. Problem persists.

Also, check just in case we had two copies of the nl2br plugin installed. Nope. So that checks out.

As far as the debug statements, the first give me this:

Code: Select all

Parse error: parse error, unexpected T_VARIABLE in /home/strumpet/public_html/plugins/serendipity_event_guestbook/serendipity_event_guestbook.php on line 404
The second, this:

Code: Select all

Warning: error_log(template_c/nl2br.log): failed to open stream: No such file or directory in /home/strumpet/public_html/plugins/serendipity_event_guestbook/serendipity_event_guestbook.php on line 404
bdconnolly
Regular
Posts: 140
Joined: Tue Apr 04, 2006 9:37 pm

Post by bdconnolly »

This fixed it. It's a kludge, i.e. not exactly sure WHY it works.

Code: Select all

                $entry = array('comment' => wordwrap(htmlspecialchars($row['shout']), $wordwrap, "\n", 1));
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Glad to hear it worked out. The debugging problems were my own; I'm still not a master at PHP, and I messed up the lines.
Judebert
---
Website | Wishlist | PayPal
Post Reply