You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 327 guest(s) and 14 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
How to get rid of the need to use <br> for new lines

18.7.1. How to get rid of the need to use <br> for new lines

It is one of the most annoying requirements for users who want to submit a News article to your site: they have to write the text either in BBcode, or in HTML. While BBcode is easy to learn and use, HTML can be a real pain for the average Jo user. Worse yet, for sites that have disabled BBcode, HTML is the only available language for the aspiring journalist. Thus, a lot of people find themselves forced to write their articles with the editor of their choice, then export that document to HTML with the editor's own export function. Although this scenario will not alleviate the need for a subsequent scrutiny of the HTML code thus produced, for the purpose of locating and eliminating the HTML tags that are not allowed by the PHP-Nuke site (see Section 16.1), it definitely has its merits, especially for long text.

Those users however, who will rather opt for a quick entering of the text directly in the form fields, will most often be reminded the hard way, by a text totally lacking paragraph structure, that something is missing from their text: two break tags (<br><br>) for the insertion of a blank line, something that is used intuitively to separate paragraphs. Even seasoned HTML coders will find themselves routinely omitting the obligatory <br> tags, so a way to avoid the need for them is great help for both beginners and specialists alike.

To eliminate the <br> plague once for all, you only have to enter a 2-liner in the modules/news/index.php file. Find the lines:

        getTopics($s_sid);
        formatTimestamp($time);
        $subject = stripslashes($subject);
        $hometext = stripslashes($hometext);
        $notes = stripslashes($notes);
        $introcount = strlen($hometext);
        $fullcount = strlen($bodytext);
        $totalcount = $introcount + $fullcount;
        $c_count = $comments;
        $r_options = "";

and append the following two ones to them:

        $hometext=nl2br("$hometext");
        $bodytext=nl2br("$bodytext");

Then, in the modules/News/article.php, find the lines

if ($notes != "") {
    $notes = "<br><br><b>"._NOTE."</b> <i>$notes</i>";
} else {
    $notes = "";
}
if($bodytext == "") {
    $bodytext = "$hometext$notes";
} else {
    $bodytext = "$hometext<br><br>$bodytext$notes";
}

and add in 2 more lines, like this:

$hometext = nl2br($hometext);
$bodytext = nl2br($bodytext);

The nl2br PHP function (newline to break) will automatically insert HTML <br /> tags (breaks) before every newline in the short ($hometext) and extended text ($bodytext) of the news article (see also How do I stop using the br tag, Linebreaks when entering text).


Help us make a better PHP-Nuke HOWTO!

Want to contribute to this HOWTO? Have a suggestion or a solution to a problem that was not treated here? Post your comments on my PHP-Nuke Forum!

Chris Karakas, Maintainer PHP-Nuke HOWTO

Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.055 Seconds - 427 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::