|
Blocks are those fun, useful little sections of content shown in the left (and right, if you have one) columns of your site. A simple block that just displays static HTML might be useful for short messages, for advertising, or even as a main menu, replacing the built-in Modules block. PHP-Nuke comes with a Sample_Block.php block, in the Blocks folder of your site, that shows how crazy-simple a block can be: <?php /**********************************************************************/ /* PHP-NUKE: Web Portal System */ /* =========================== */ /* */ /* Copyright (c) 2002 by Francisco Burzi */ /* http://phpnuke.org */ /* */ /* This program is free software. You can redistribute it or modify */ /* it under the terms of the GNU General Public License published by */ /* the Free Software Foundation; either version 2 of the License. */ /**********************************************************************/ if (eregi("block-Sample_Block.php",$_SERVER['PHP_SELF'])) { header("Location: index.php"); die(); } $content = "Here goes the content you want in your new block"; ?> As you can see, something like 75 percent of this block is comments, and there are only five lines of code. The first four lines simply check to make sure the block is being loaded by another page of the site, not being accessed directly; these four lines should be copied over to any blocks you create. The next line shows, with an almost Zen-like efficiency, how blocks work: You put your content into a variable named $content. That's it. If you were to load this sample block into your Web site (by using the Blocks administration module), it would look like Figure 40.1. Figure 40.1. The sample block displayed on the home page.I mean, seriously, that's easy stuff. |
|