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, 348 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
How to include a plain text file in a PHP-Nuke module

21.8. How to include a plain text file in a PHP-Nuke module

A plain text file needs a somewhat different treatment than a HTML file, if it is to be included in a PHP-Nuke module. The reason is that a plain text file lacks the formatting tags that are present in a usual HTML file. If you simply include it as shown in Section 21.5, it will show as a single paragraph, lacking any structure.

Why? Because the "formatting tags" of a plain text file are the newline characters. They will introduce a new line - and a new paragraph. In HTML however, a newline will not suffice, you need a break tag (<br>) to achieve the same effect. Since a PHP-Nuke module is a PHP file, and as such it will be transformed to a HTML file for the visitor, we need to play by the HTML rules if we want our file to be formatted correctly.

Fortunately, the nl2br PHP function (newline to break) comes to our rescue here: it will automatically insert HTML <br /> tags (breaks) before every newline in the text file. Replace

OpenTable();
include("path/to/the/html/file"); // <-- CHANGE THIS!
CloseTable();

in the code of Section 21.5 with (see another adding module question):

OpenTable();
$filename = "path/to/the/text/file"; // <-- CHANGE THIS!
$content_array = file($filename);
$content = implode("", $content_array);
print nl2br($content);
CloseTable();

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.023 Seconds - 190 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::