Creating Static Web Portals using NukeLayout

Presentation given at the Web Technologies SIG at HAL-PC

First I'm a network administrator and php developer. Not a writer

What is a static site?
My Answer: A site where the content doesn't change that often.

Why have a static site?
My Answer:Because your content doesn't require a database backend, you don't have access to a database server and/or you don't want to have to maintain a database driven site.

Or your content will not change so having it in a database is not required.

What is NukeLayout PHP Class?
A OO class that creates a predefined layout for static content driven web sites. It's design allows the content to be the primary focus.

What development environment was NukeLayout created?
It was developed on a Laptop running Mandrake 7.2, Apache 1.3.x and php 4.1.x.
Development tool used: nedit and vi

Since this application has not been tested by me using the windows version of PHP your mileage may vary. I currently don't have a windows web development environment running on my home lan to test against. (It should work, if not...)

Where can I get Nukelayout?
Visit http://www.pccs-linux.com/
Here you will find example code and pages that can be created using this class.

How do I install nukelayout?
Download the lastest version and extract the files from the archive to a directory under your http server wwwroot.
Modify the globalinclude.php. change the path to etc/nukelayoutclass.php and modify

The basics!

How do I load the class file in my scripts?

<?php
ob_start();
require('globalinclude.php');


ob_end_flush();
?>

Example globalinclude.php file
<?php

/******************************************************************/
/** don't allow anyone to load file directly **/

if (eregi('globalinclude.php', $PHP_SELF)) {
    die ("ERROR File not found ...");
}

// Defined the location of the layout directory
// you will need to modify this value!!!

$INCLUDE_DIR = "/home/www/htdocs/nukelayout/etc/";

// Make sure they defined
// not needed just a check...

if(!isset($INCLUDE_DIR)) {
    die ("You must assign a value to \$INCLUDE_DIR ...");
}

// make sure the class file it's there
if(!file_exists($INCLUDE_DIR ."nukelayoutclass.php")) {

        print "The Class script is not in $INCLUDE_DIR";
        print "Check the \$INCLUDE_DIR value ";
        exit;

} else {
// load the include file
        require_once ($INCLUDE_DIR ."nukelayoutclass.php");

}
 
// make sure the nukeLayout class exist
if(class_exists('nukeLayout')) $mypage = new nukeLayout;

/******************************************************************/

// create your color theme here..
// themes moved here to reduce number of config files
//
// bgcolor = "441215"; //Page background color, for readability reasons should not be the same as any text or link color
// sectionheader = "643235"; //Background color of top banner and header area
// headertextColor = "8c8f72"; //Color of text used in top banner and header area
// sectionbody = "643235"; //Background color of section boady area
// trimcolor = "8c8f72"; //Color used for border of boxes
// textcolor = "FFFFFF"; //Text color, for readability reasons should not be the same as bgcolor
// linkcolor = "FFFFFF"; //Text color of a link, for readability reasons this should not be the same as bgcolor or textcolor
// vlinkcolor = "FFFFFF"; // Text color of a visited link
// alinkcolor = "FFFFFF"; // Text color of an active link
// hlinkcolor = "0080C0"; // CSS Hover text color, this is the color used when your mouse passes over the text link
//
//

// turned theme into an array
// Chauncey Thorn 
// 
// this required me to change set_layoutTheme() 

$nukelayout_theme = array(

        "forest"=>array("bgcolor"=>"003F00","sectionheader"=>"997F00",
                        "sectionbody"=>"997F00","headertextColor"=>"003F00",
                        "trimcolor"=>"CC9F00","textcolor"=>"FFFFFF",
                        "linkcolor"=>"FFFFFF","vlinkcolor"=>"FFFFFF",
                        "alinkcolor"=>"FFFFFF","hlinkcolor"=>"0080C0"),

        "hlug"=>array("bgcolor"=>"666666","sectionheader"=>"FF9900",
                      "sectionbody"=>"303030","headertextColor"=>"FFFFFF",
                      "trimcolor"=>"CC9F00","textcolor"=>"FFFFFF",
                      "linkcolor"=>"FFFFFF","vlinkcolor"=>"FFFFFF",
                      "alinkcolor"=>"FFFFFF","hlinkcolor"=>"CC9F00"),

        "lightblue"=>array("bgcolor"=>"0066FF","sectionheader"=>"0099FF",
                           "sectionbody"=>"0099FF","headertextColor"=>"FFFFFF",
                           "trimcolor"=>"000066","textcolor"=>"FFFFFF",
                           "linkcolor"=>"FFFFFF","vlinkcolor"=>"FFFFFF",
                           "alinkcolor"=>"FFFFFF","hlinkcolor"=>"000066"),

        "midnight"=>array("bgcolor"=>"000033","sectionheader"=>"336699",
                          "sectionbody"=>"336699","headertextColor"=>"003366",
                          "trimcolor"=>"003366","textcolor"=>"FFFFFF",
                          "linkcolor"=>"FFFFFF","vlinkcolor"=>"FFFFFF",
                          "alinkcolor"=>"FFFFFF","hlinkcolor"=>"003366"),

        "white"=>array("bgcolor"=>"FFFFFF","sectionheader"=>"FFFFFF",
                          "sectionbody"=>"FFFFFF","headertextColor"=>"000066",
                          "trimcolor"=>"FFFFFF","textcolor"=>"000066",
                          "linkcolor"=>"004080","vlinkcolor"=>"004080",
                          "alinkcolor"=>"004080","hlinkcolor"=>"0080C0")                                        
);

// create theme var 
// used in set_layoutTheme()
// $nukelayout_theme[$theme][bgcolor]

$theme = "midnight";


$site_fonts = "Verdana, Arial, Helvetica, Sans-Serif"; //CSS names used to define preference of font type used, for OS reasons stay away from wierd fonts that the target PC may not have

// set_nukeLayout()
// Defined SiteName
// Logo Image file name
// Greeting ON/OFF
// Logo placement (left,center,right)

$mypage->set_nukeLayout("NukeLayout php Class", "nukelayout.jpg","OFF", "left");

// Left/Right Column ON/OFF
$mypage->set_columnStatus("ON","ON");

// Top/Bottom banner ON/OFF 
// Logo Active link ON/OFF 
$mypage->set_bannerStatus("ON","ON","OFF");


// Set Page title 
// You may want to move this to each script
$mypage->set_pageTitle("NukeLayout PHP Class 1.1");

// set e-mail addr and page owner name
$mypage->set_pageOwner("cthorn", "Chauncey Thorn");

// this is site META description
$mypage->set_Metadata("This is Chauncey Thorn's Web Site");

// Text that is to be displayed in bottom banner footer
$mypage->set_layoutfooterText("NukeLayout PHP Class");

// Main Menu links 
$mypage->nukelayoutmenuLink_array = array("HOME"=>"./",
                "Developers Site"=>"rhttp://www.pccs-linux.com/");

// Quick Links displayed under Top banner
$quicklink_array = array("Linux"=>"http://www.linux.com/",
                         "Linux1"=>"http://www.linux.com/",
                         "Linux2"=>"http://www.linux.com/",
                         "Linux3"=>"http://www.linux.com/",
                         "Linux4"=>"http://www.linux.com/",
                         "MySQL"=>"http://www.mysql.com/");


$mypage->nukelayoutbasehref = "http://mylaptop/nukelayout/";

?>

A very basic example of how to use the class
<?php
ob_start();

// load the class and default values for each script
require('globalinclude.php');

// Create left side of page
$mypage->addleftBar("Web Technology Sig","This meeting is about PHP");

// Create another left bar 
$mypage->addleftBar("Left Column 2","content");

// A left bar with Links using standard HTML

$mypage->addleftBar("Left Column 1","
<A HREF=view_src.php?page=example3.php>View Src<br>
<A HREF=example1.php>No Right Column<br>
<A HREF=example2.php>No Bottom Banner<br>
<A HREF=example3.php>No Top Banner<br>
");
 
// Create Article section
$mypage->addArticle("NukeLayout Class","This is content for the center");
 
$mypage->addArticle("Ease of Use","content");
 
 
// Create right side of page
$mypage->addRightBar("Right Column 1","content");
 
$mypage->addRightBar("Right Column 2","content");
 
// render your page 
$mypage->render();

ob_end_flush();
?>

A more advance example.
<?php
ob_start();

// load the class and default values for each script
require('globalinclude.php');

// left side of page

// A left bar with Links using an array 
// Using internal function that will take an array of links 
// Setup your link array 
$navlinks = array( "View Src"=>"view_src.php?page=example3.php",
             "No Right Column"=>"example1.php",
             "No Bottom Banner"=>"example2.php",
             "No Top Banner"=>"example3.php");
 
// pass it to the function, creating a variable
// to be passed on the the create left bar function
 
$mynavlinks = $mypage->displaymyLinks($navlinks);


// create left bar using links in array
$mypage->addleftBar("Support Options","$mynavlinks");

// display a random text quote in this left bar
// using an internal function

$thisquote = $mypage->getrandQuote("randomquotes.txt");
$mypage->addleftBar("Random Text Quote","$thisquote");


// Center of page ...

// a csv file can be used to provide data for your article(s)  
// filname 
$csvfile = 'Products.txt';

// make sure it's a file and can be read 
if(!is_file($csvfile) || !is_readable($csvfile)) {
        die('ERROR: We have a problem');
}
 
//the file for reading 
$fp = f$csvfile, 'r');

while($data = fgetcsv($fp, 1000, ",")) {
 
        $productname = "<B>". $data[1] . "</B>";
        $productdesc = wordwrap($data[2],8);

        // pass the results to the add article function 
        $mypage->addArticle("$productname","$productdesc");
}
fclose($fp);

// right side of page

// using the addons include a stock quote 
$rh_quote=new php_quote;
 
$rh_quote->get_single_quote("RHAT");
 
$mypage->addRightBar("Stock Quote  <br>(20 min. delay)","
<font size=\"2\">
<li><b>Symbol: $rh_quote->Symbol</li>
<li><b>Last Trade:$rh_quote->Last </li>
<li><b>Price:$rh_quote->Price</li>
<li><b>Change:$rh_quote->Change</li>
<li><b>% Change:$rh_quote->PercChange</li>
<li><b>Volume:$rh_quote->Volume<p>
 
</font>
");
 
// Random images 

// directory name where images are located
$dirpath = "randimg";

// pass that info to the image function
$images = $mypage->getrandomImage($dirpath);
 
// pass that data to either your left or right bar functions
$mypage->addRightBar("Random Images","<IMG SRC=$images BORDER=0>");
 
// render the page
$mypage->render();

ob_end_flush();
?>

End ...
A brief introduction to building static web portals using Nukelayout.
You can see example out put at http://pccs-linux.com/nukelayout/demolastest/
Chauncey Thorn
http://pccs-linux.com/
PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002