Flexible Content Management System


Addressing the nl2br issue

Contributed by Very good idea and s on Jul 06, 2002 - 02:13 PM

We now allow various html elements to be placed in stories and faqs etc, but both of these modules conver every new line to a <br /> which causes quite serious formatting issues.

This is a suggestion on how this problem could be addressed, which may also be applicable to the other config variable we set in PN

The first step would be to create a pnNL2BR() function in pnHTML . All occurences of nl2br() in the core code would then be replaced with the pnNL2BR().

We then need to be able to define when newlines are converted and when they are not.

We need to create a 'default hierarchy'. The 'Convert NL to BR' variable neds to be set(able) at site, module and item (individual article, faq answer etc) levels.

Each lower level (if set) overrides the higher level.

For example: Most of your site's input is from contributors who have little knowledge of HTML. So the site default of 'Convert NL to BR' would be 'Yes'.

However, your FAQ answers are maintained by and HTML guru who like complete control over formatting. So for the module FAQ, the 'Convert NL to BR' is set to 'No'. Occasionally, the Guru receives an FAQ answer via email and wants to 'cut and paste' without any changes. For this particular FAQ answer, the 'Convert NL to BR' would be set to 'Yes'

pnNL2BR() would check the hierarchy from the bottom up, deciding wether or no to do the newline to 'br /' conversion.

This hierachy of config values really needs to be applied to many of the config settings in PN - giving admins the flexibility they crave...