17.2.1. Simple module block

The links that are inside the standard PHP-Nuke module block are constructed dynamically, using information that is available about the modules in the database. For example, to present only active modules in the links, the block (located in blocks/block-Modules.php) checks the "active" field of the $prefix_modules table (which is table nuke_modules, if $prefix is left to the standard "nuke" in config.php, see Section 3.7):

$sql = "SELECT title, custom_title FROM ".$prefix."_modules 
WHERE active='1' AND inmenu='0' ORDER BY title ASC"; 

As we can easily read in the SELECT query above, only modules with the "active" bit set to 1 are selected. But we also see that the order in which they are selected is the standard ascending lexicographic order of the modules' title (ORDER BY title ASC). If we wish a different ordering, we are left with only a few possibilities:

But if we wish a custom grouping of the modules links, we will have to write our own modules block. You can use the following code as a starting point for your own creations. This script will display certain links only when an admin or user is logged in. Just name it block-menuSample.php and put in the blocks folder, deactivate the block-Modules.php and activate this one (see Different links - some for registered users only and How would I add a clickable link in a Modules Block?):

<?php
if (eregi("block-menuSample.php",$PHP_SELF)) {
Header("Location: index.php");  
die(); 
}
Global $user, $admin; 
$title = "Main Menu";
$content = "
<font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">
<B><u>Navigation</u>
<BR> 
<STRONG><BIG>·</BIG></STRONG> 
<a href=index.php>Start Page</a><br><br>
<u>Information</u><BR>
<STRONG><BIG>·</BIG></STRONG> 
<A href=\"modules.php?name=News&file=index\">News</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=aboutus\">About us</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=somefolder&file=index\">Entry with Some word</A><BR>
<BR>
<u>Other things</u>
<BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Web_Links
&amp;file=index&amp;l_op=viewlink&amp;cid=1\">Links</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=My_eGallery\">All sorts of Pictures</A><br>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Reviews\">Reviews</A><BR>
<BR>
<u>Interact</u>
<BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=GuestBook\">Guestbook</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Feedback\">Feedback</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Recommend_Us\">Recommend Us</A><BR>
<BR>
<u>Misc.</u>
<BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Web_Links\">Links</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=FAQ\">FAQ</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Web_Links
&amp;file=index&amp;l_op=AddLink\">Add A Link</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Downloads\">Downloads</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Statistics\">Site Statistics</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=HeadLines\">News Headlines</A><BR>
<BR>
//******************************************
//Below is for users and admins ONLY!!! 
//******************************************
<u>User Control Panel</u>
<BR>";  
if (!IsSet($user))
{;
$content .= "
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Your_Account\">Reg. Users Login. </A><br>";
}
if ((IsSet($user)) or (IsSet($admin)))
{;
$content .= "
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Your_Account\">Your Account</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Your_Account&amp;op=edituser\">Edit Profile</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Members_Photo_Upload\">Members Photo upload</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Members_List\">View Member List</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Your_Account&amp;op=logout\">logout</A><BR>
<BR>
<u>Private Messages</u>
<BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Private_Messages\">View Messages</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Private_Messages
&amp;file=reply&amp;send=1\">Compose A Message</A><BR>
";
};
//***************************************
//ENDS HERE
//***************************************
$content .= "
<BR>
<u>Send Content</u>
<BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Submit_News\">Submit News</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Reviews&amp;rop=write\">Write A Review</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=Web_Links
&amp;file=index&amp;l_op=AddLink\">Add A Link</A><BR>
<STRONG><BIG>·</BIG></STRONG>
<A href=\"modules.php?name=My_eGallery
&amp;file=index&amp;do=upload\">Add modules/PHP-Nuke_HOWTO/images to the Gallery</A><BR>
<BR>
</font>
</B>
<HR size=3>
";
?>

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