Using Static HTML


I mentioned that you can make your own main menu. Normally, your site would just use the provided Modules block, which PHP-Nuke automatically formats into a main menu. It lists all active modules that are configured to show in the Modules block, making a simple yet effective main menu. At one time, I had my site at www.scriptinganswers.com using a completely custom menu, though. I started in Microsoft FrontPage, building the menu out of graphics I'd created and linking each graphic to a module of my site. The resulting HTML, which I copied out of FrontPage, looked like this:

[View full width]

<center> <img border=\"0\" src=\"images/menu/MenuStack_01.png\" ><br> <img border=\"0\" src=\"images/menu/MenuStack_02.png\" ><a href=\"modules .php?name=News&new_topic=3\"><img border=\"0\" src=\"images/menu/MenuStack_03.png\" alt= \"VBScript, WSH, WMI, &amp; ADSI\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_04.png\" ><a href=\"modules .php?name=News&new_topic=4\"><img border=\"0\" src=\"images/menu/MenuStack_05.png\" alt= \"Commandline scripts\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_06.png\" ><a href=\"modules .php?name=News&new_topic=5\"><img border=\"0\" src=\"images/menu/MenuStack_07.png\" alt= \"MSH scripts\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_08.png\" ><a href=\"modules .php?name=Submit_News\"><img border=\"0\" src=\"images/menu/MenuStack_09.png\" alt=\"Submit content\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_10.png\" ><br> <img border=\"0\" src=\"images/menu/MenuStack_11.png\" ><a href=\"modules .php?name=News&new_topic=2\"><img border=\"0\" src=\"images/menu/MenuStack_12.png\" alt= \"Announcements\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_13.png\" ><a href=\"modules.php?name=Forums \"><img border=\"0\" src=\"images/menu/MenuStack_14.png\" alt=\"Discussion forums\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_15.png\" ><a href=\"modules .php?name=Downloads\"><img border=\"0\" src=\"images/menu/MenuStack_16.png\" alt= \"Downloads\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_17.png\" ><a href=\"modules .php?name=Web_Links\"><img border=\"0\" src=\"images/menu/MenuStack_18.png\" alt=\"Web links\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_19.png\" ><br> <img border=\"0\" src=\"images/menu/MenuStack_20.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=1\"><img border=\"0\" src=\"images/menu/MenuStack_21.png \" alt=\"About Don / Contact info\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_22.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=2\"><img border=\"0\" src=\"images/menu/MenuStack_23.png \" alt=\"Don's books &amp; e-books\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_24.png\" ><a href=\"modules .php?name=Calendar\"><img border=\"0\" src=\"images/menu/MenuStack_25.png\" alt=\"Training &amp; Events Calendar\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_26.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=3\"><img border=\"0\" src=\"images/menu/MenuStack_27.png \" alt=\"Consulting services\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_28.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=4\"><img border=\"0\" src=\"images/menu/MenuStack_29.png \" alt=\"Public speaking\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_30.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=5\"><img border=\"0\" src=\"images/menu/MenuStack_31.png \" alt=\"Public &amp; Private Training\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_32.png\" ><br> <a href=\"modules.php?name=Content&pa=showpage&pid=1\"> <img border=\"0\" src=\"images/menu/MenuStack_33.png\" width=\"47\" height=\"38\" alt= \"Contact\"></a><a href=\"modules.php?name=Your_Account\"><img border=\"0\" src=\"images /menu/MenuStack_34.png\" alt=\"Your Account\"></a><a href=\"modules.php?name=Search\"><img border=\"0\" src=\"images/menu/MenuStack_35.png\" width=\"42\" height=\"38\" alt=\"Search \"></a><a href=\"index.php\"><img border=\"0\" src=\"images/menu/MenuStack_36.png\" width= \"48\" height=\"38\" longdesc=\"Home\"></a> <img border=\"0\" src=\"images/menu/MenuStack_37.png\"><a href=\"modules.php?name=Journal \"><img border=\"0\" src=\"images/menu/MenuStack_38.png\" alt=\"Journal\"></a><a href= \"http://www.scriptinganswers.com/shop\"><img border=\"0\" src=\"images/menu/MenuStack_39 .png\" alt=\"Online Store\"></a><a href=\"modules.php?name=Private_Messages\"><img border= \"0\" src=\"images/menu/MenuStack_40.png\" alt=\"Private Messages\"></a><img border=\"0\" src=\"images/menu/MenuStack_41.png\"> </center>

Don't worry about the crazy way the text wraps from line to line; FrontPage did it that way and didn't seem to care. So how do I convert this into a block for use in PHP-Nuke? I have to type exactly 21 additional characters. Before the HTML, I typed this:

 <?php $content = "' 

And after it, I typed this:

 "; ?> 

The resulting file looks like this:

[View full width]

<?php $content = "<center> <img border=\"0\" src=\"images/menu/MenuStack_01.png\" ><br> <img border=\"0\" src=\"images/menu/MenuStack_02.png\" ><a href=\"modules .php?name=News&new_topic=3\"><img border=\"0\" src=\"images/menu/MenuStack_03.png\" alt= \"VBScript, WSH, WMI, &amp; ADSI\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_04.png\" ><a href=\"modules .php?name=News&new_topic=4\"><img border=\"0\" src=\"images/menu/MenuStack_05.png\" alt= \"Commandline scripts\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_06.png\" ><a href=\"modules .php?name=News&new_topic=5\"><img border=\"0\" src=\"images/menu/MenuStack_07.png\" alt= \"MSH scripts\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_08.png\" ><a href=\"modules .php?name=Submit_News\"><img border=\"0\" src=\"images/menu/MenuStack_09.png\" alt=\"Submit content\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_10.png\" ><br> <img border=\"0\" src=\"images/menu/MenuStack_11.png\" ><a href=\"modules .php?name=News&new_topic=2\"><img border=\"0\" src=\"images/menu/MenuStack_12.png\" alt= \"Announcements\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_13.png\" ><a href=\"modules.php?name=Forums \"><img border=\"0\" src=\"images/menu/MenuStack_14.png\" alt=\"Discussion forums\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_15.png\" ><a href=\"modules .php?name=Downloads\"><img border=\"0\" src=\"images/menu/MenuStack_16.png\" alt= \"Downloads\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_17.png\" ><a href=\"modules .php?name=Web_Links\"><img border=\"0\" src=\"images/menu/MenuStack_18.png\" alt=\"Web links\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_19.png\" ><br> <img border=\"0\" src=\"images/menu/MenuStack_20.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=1\"><img border=\"0\" src=\"images/menu/MenuStack_21.png \" alt=\"About Don / Contact info\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_22.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=2\"><img border=\"0\" src=\"images/menu/MenuStack_23.png \" alt=\"Don's books &amp; e-books\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_24.png\" ><a href=\"modules .php?name=Calendar\"><img border=\"0\" src=\"images/menu/MenuStack_25.png\" alt=\"Training &amp; Events Calendar\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_26.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=3\"><img border=\"0\" src=\"images/menu/MenuStack_27.png \" alt=\"Consulting services\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_28.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=4\"><img border=\"0\" src=\"images/menu/MenuStack_29.png \" alt=\"Public speaking\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_30.png\" ><a href=\"modules .php?name=Content&pa=showpage&pid=5\"><img border=\"0\" src=\"images/menu/MenuStack_31.png \" alt=\"Public &amp; Private Training\"></a><br> <img border=\"0\" src=\"images/menu/MenuStack_32.png\" ><br> <a href=\"modules.php?name=Content&pa=showpage&pid=1\"> <img border=\"0\" src=\"images/menu/MenuStack_33.png\" width=\"47\" height=\"38\" alt= \"Contact\"></a><a href=\"modules.php?name=Your_Account\"><img border=\"0\" src=\"images /menu/MenuStack_34.png\" alt=\"Your Account\"></a><a href=\"modules.php?name=Search\"><img border=\"0\" src=\"images/menu/MenuStack_35.png\" width=\"42\" height=\"38\" alt=\"Search \"></a><a href=\"index.php\"><img border=\"0\" src=\"images/menu/MenuStack_36.png\" width= \"48\" height=\"38\" longdesc=\"Home\"></a> <img border=\"0\" src=\"images/menu/MenuStack_37.png\"><a href=\"modules.php?name=Journal \"><img border=\"0\" src=\"images/menu/MenuStack_38.png\" alt=\"Journal\"></a><a href= \"http://www.scriptinganswers.com/shop\"><img border=\"0\" src=\"images/menu/MenuStack_39 .png\" alt=\"Online Store\"></a><a href=\"modules.php?name=Private_Messages\"><img border= \"0\" src=\"images/menu/MenuStack_40.png\" alt=\"Private Messages\"></a><img border=\"0\" src=\"images/menu/MenuStack_41.png\"> </center>"; ?>

I saved the file as MainMenu.php in the Blocks folder of my site. Then I just selected that block in the Blocks administration module and added the block to my site. Shazam, new static HTML block. I know people are all the time telling you how simple things are, but this really is that simple.

Sidebar . FRIDGE

Speaking of people who lie about how simple things are, I recently bought one of those assemble-it-yourself computer desks. Now, I've put these pieces of furniture together before, and while it usually isn't much fun, it's not exactly nuclear engineering, either. But this "simple to assemble" desk had something like 4.2 million parts, and the instructions consisted of one exploded diagram showing every piecenone of which was labeledfitting together. Yeah, right. I got it together, though, and it's one of the largest ashtrays I've ever owned, although I'm still not sure why an ashtray needs cord management piping. Oh, wait….


To take a simpler-looking example, suppose you just wanted a block that invites people to visit another Web site you've got. Here's what you'd do:

 <?php if (eregi("block-Sample_Block.php",$_SERVER['PHP_SELF'])) {     header("Location: index.php");     die(); } $content = "Visit <a href=\"http://www.mysite.com\">My site!</a>"; ?> 

That's it. I do want you to notice something in particular: The process of assigning content to the $content variable requires that your content be enclosed in double quotes. See the quotes at either end? The line must also end in a semicolon, although the line can happily take up more than one actual line of text if it's really long.

Sometimes, however, you need to use double quotes as part of your content. In the previous example, the <a> tag requires double quotes around the URL that I want to link to. Those double quotes must be preceded by the backslash (\) character, a process called escaping. The backslash basically tells PHP to not worry about the next character and to not treat it like a double quote mark. You'll notice the same technique usedquite liberallyin my main menu example that I showed you earlier.

Anyway, once you've finished your block, save it in a PHP file in the Blocks folder of your site, and you're ready to go.



    PHP-Nuke Garage
    PHP-Nuke Garage
    ISBN: 0131855166
    EAN: 2147483647
    Year: 2006
    Pages: 235
    Authors: Don Jones

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net