Can I let people use   in the body of a message?

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
sbolinger
Registered User
Posts: 4
Joined: Sun Sep 15, 2002 6:46 am

Can I let people use   in the body of a message?

Post by sbolinger »

Does anyone know a way that I can allow users to use   in the body of messages?

I have many users that copy/paste html posts and they'd like to be able to format them with non-breaking spaces. Is this possible? I tried adding " " to the allowed html list, but no luck.

Any ideas and/or solutions? Thanks!
DanielT
Former Team Member
Posts: 3324
Joined: Tue Aug 27, 2002 10:55 am
Contact:

Post by DanielT »

have u enabled html ??
sbolinger
Registered User
Posts: 4
Joined: Sun Sep 15, 2002 6:46 am

Yes, I enabled HTML

Post by sbolinger »

Yes, I enabled HTML. But when you enable it, it still only allows the tags you put in the allow list. And the allow list doesn't accept ' '..

Any other ideas?
chris_blessing
Registered User
Posts: 15
Joined: Mon Apr 05, 2004 2:50 pm

Post by chris_blessing »

EDIT: I came up with a much easier addition which allows users to simply enter multiple spaces with the chr(10) character rather than making them type out   everytime. Much much easier on the user if you want to allow them to do this... so I've updated this post.

It's just a simple post-processing addition after the post has been "prepared" by the "stock" function. You could mod this up further to allow administration from the ACP but I am enabling it globally. Here's the code:

open includes/functions_post.php

find:

Code: Select all

		$message = bbencode_first_pass($message, $bbcode_uid);
	}
after, add

Code: Select all

	// allow some html entities in post mod
	$message = replace_double_spaces($message);

find:

Code: Select all

?>
before, add:

Code: Select all

// allow some html entities in posts mod
function replace_double_spaces($message)
{
	// allow some html entities in posts mod
	$nbsp_match = '/  /';
	$nbsp_replace = '  ';
	
	// replace all instances of double-spaces with a single space +  
	$message = preg_replace($nbsp_match, $nbsp_replace, $message);

	return $message;
}

save and close functions_post.php


It will work for any post, editing/quoting/new/whatever. The web browser may show the   string from the post (when it's extracted from the db) as a regular space in the post textarea, but that's ok because you can just add/delete spaces as necessary and they'll be persisted!

Forum mods: my apologies if this is the wrong forum to be submitting code/etc. If it is please move it appropriately, thanks! :)
kswat
Registered User
Posts: 8
Joined: Fri Aug 27, 2004 7:39 am

Re: Yes, I enabled HTML

Post by kswat »

sbolinger wrote: Yes, I enabled HTML. But when you enable it, it still only allows the tags you put in the allow list. And the allow list doesn't accept ' '..

Any other ideas?


I am now facing your problem. Have you enabled ' ' to be displayed as spaces ??
Locked

Return to “2.0.x Support Forum”