[SOLVED] Turning off auto <br />

Post Reply
matthewdickens
Posts: 2
Joined: Fri Sep 23, 2011 12:01 am

[SOLVED] Turning off auto <br />

Post by matthewdickens »

Is there any code that can be changed to disabled so that a <br /> won't be created when a line break is typed? In the textarea, I'm using <p> tags, and after my </p> I hit enter to start a new line, but it's creating </p><br /> in the code.

I looked through the editInline.js script, but I'm not very fluent in JavaScript. The only thing that I could find was the line than hides the <br /> when you're editing.
Matthew Dickens
matthewdickens@me.com

User avatar
wiz
Admin
Posts: 671
Joined: Sat Oct 30, 2010 12:23 am

Re: Turning off auto <br />

Post by wiz »

Matthew, it's made in a way you don't need to make a new paragraph (<p></p>) since entering a new line does the same effect, unless you're worried about optimizing it with W3C.

There could be a workaround but it would take some customizing to all of the files.

peterholthoffman
Posts: 1
Joined: Tue Feb 07, 2012 4:04 pm

Re: Turning off auto <br />

Post by peterholthoffman »

I was looking into this because I need to support TABLE for some tabular data. The first thing I had to do was change editText.php so the call to strip_tags() would allow things like TABLE, THEAD, etc.

Then I found I was getting a lot of vertical white space in the rendered page that I didn't want. This was because I format the HTML to be legible in a text editor (e.g., a newline after each closing tag).

I went into editText.php and commented out

Code: Select all

$content = nl2br($content);
which solved my TABLE issue nicely. However, I found it then breaks how defining menus works as the newline is used as the delimiter there.

To fix how the menu system works, I edited index.php and changed the function displayMenu($stags,$etags) so it does an explode using the "|" symbol instead of "<br />" like this:

Code: Select all

$mlist = explode("|",$menu);
Then I changed my menu definition to be like "Home|About|Contact|Map" instead of having each page on a separate line.

I think everything else is still working but I might be wrong. Does anyone else see a problem with what I have done? Will it break something and I've just not seen it yet?

xss
Developer
Posts: 22
Joined: Thu May 26, 2011 9:07 pm

Re: Turning off auto <br />

Post by xss »

Hello peter,

indeed, I also was missing many important tags and added some more exceptions to the strip_tags() function for my site.

Your second change (commenting out nl2br($content)) might be a problem for a layout outside of tables — not sure, though, will have to test that.

About your third change: That might work fine for your purpose. However, a better way might be to adjust the parameters when calling this function — after all, the variables $stag and $etag in displayMenu($stags,$etags) stand for start tag and end tag. ;)

The function is called twice (once for the top menu, once for the footer navi) from default.php (or whatever your theme's PHP file might be). A quick and dirty way could be something along the lines:

Change line

Code: Select all

displayMenu("<li><a ","</a></li>");
to

Code: Select all

displayMenu("<a ","</a> | ");
or

Code: Select all

displayMenu("<li><a ","</a></li> | ");
To have the top menu displayed like "Home | About | Contact | Map | ". As you see, it would result in a " | " paired with each menu element, though (as in the footer by default). It could be avoided with some more code, but it doesn't necessarily have to be a bad thing. ;)

Anyway, I think that in order to be as free and flexible as possible for making themes for WonderCMS, the menu layouting should be ‚outsourced‘ to the theme specific PHP code. There will probably be a new development section in these forums, soon, where such things can be suggested and discussed in depth. :) (I'm ready to fire away as soon as it's there, too... :D)

Kind regards,
xss
¿ן ʇ,uop 'spɹɐʍʞɔɐq ןןɐ ʇı ʇoƃ ן 'ɹɐǝp ɥo

Post Reply