NP_RowNav.php

This plugin uses the categories to create a new row based navigation menu. Use <%RowNav%(options)%>.

General Plugin info
Author: .:fran
Current Version: 1.0
Download: -
Code: code
Demo: -
Forum Thread: -

Code

<?
 
/************************************************************************ 
 
  NP_RowNav.php v1.0 by .:Fran
 
	This plugin uses the categories to create a row based navigation
	menu.
 
    Updates and documentation can be found here on the [[Nucleus]] Wiki:
    http://wakka.[[xiffy]].nl/[[NPRowNavphp]]/
 
    History:
      v1.0  - Initial release.
 
	ToDo:
      * errr, does everything i need right now!
 
 
************************************************************************/
 
class NP_RowNav extends [[NucleusPlugin]] {
 
    //we love nucleus
    function getEventList()         { return array(); }
    function getName()              { return 'RowNav'; }
    function getAuthor()            { return '.:fran'; }
    function getURL()               { return 'http://wakka.[[xiffy]].nl/[[NPRowNavphp]]/'; }
    function getVersion()           { return '1.0'; }
	function getMinNucleusVersion() { return 200; }
    function getDescription()       { return 'This plugin uses the categories to create a new row based navigation menu. Use <%RowNav%(options)%>'; }
    function supportsFeature($f)    {
        switch ($f)                 { case   'SqlTablePrefix'     : return 1;
                                      default                     : return 0; } }
 
    function install() { 
	   // create some options
	   $this->createOption('PreNav','String to insert before the nav row','text',); 
   	   $this->createOption('PosNav','String to insert after the nav row','text',); 
	   $this->createOption('LinkClas','Class to use for link span','text','row_link'); 
	   $this->createOption('Cat0Name','Name of Home/All/Index category','text','Home'); 
	   $this->createOption('Cat0Desc','Description of Home/All/Index category','text','the latest items from all categories'); 
	   $this->createOption('SpaceStr','String to use to seperate links','text','&nbsp;|&nbsp;'); 
   	   $this->createOption('PreActiv','String to insert before the active link','text','&nbsp;&nbsp;'); 
   	   $this->createOption('PosActiv','String to insert after the active link','text','&nbsp;&nbsp;');
   	   $this->createOption('AddAdmin','Add an [[admin]] link to the end of the row?','yesno','no'); 
    } 
 
    function doSkinVar($skinType) {
	    global $[[blog]], $manager, $CONF;
 
	    //define options
	    $PreNav = $this->getOption('PreNav');
		$PosNav = $this->getOption('PosNav');
		$LinkClas = $this->getOption('LinkClas');
		$Cat0Name = $this->getOption('Cat0Name');
	    $Cat0Desc = $this->getOption('Cat0Desc');
	    $SpaceStr = $this->getOption('SpaceStr');
		$PreActiv = $this->getOption('PreActiv');
		$PosActiv = $this->getOption('PosActiv');
		$AddAdmin = $this->getOption('AddAdmin');
 
	    //get categories
		$currcat = $[[blog]]->selectedcatid;
		$currblog = $[[blog]]->blogid;
	    $sql = 'SELECT catid, cname, cdesc FROM '.sql_table('category').' WHERE cblog='.$currblog;
        $categories = sql_query($sql);
	    $numcats = mysql_num_rows($categories);
 
	    //define row class
		$RowNav = $PreNav;
 
		//add index link
		if($currcat != 0) {
		    $RowNav .= "<a class=\<nowiki>.$LinkClas."\" href=\</nowiki>.$CONF['IndexURL']."index.php?catid=0&blogid=".$currblog."\" title=\<nowiki>.$Cat0Desc."\">";
			$RowNav .= $Cat0Name."</a>";
	    } else $RowNav .= $Cat0Name.$PosActiv;
		$RowNav .= $SpaceStr;
 
		//add the rest of the links
		$x = 0;		
	    while ( $category = mysql_fetch_assoc($categories) AND $x < $numcats) {
	        $ThisLink = </nowiki>;
		    if($category['catid'] != $currcat) {
			    $ThisLink .= "<a class=\"$LinkClas\" href=\<nowiki>.$CONF['IndexURL']."index.php?catid=".$category['catid']."&blogid=".$currblog."\" title=\</nowiki>.$category['cdesc']."\">";
				$ThisLink .= $category['cname']."</a>";
			} else $ThisLink .= $PreActiv.$category['cname'].$PosActiv;
		    $x = $x + 1;
		    if($x != $numcats OR $AddAdmin == 'yes') $ThisLink .= $SpaceStr;
            $RowNav .= $ThisLink;
	    }
 
		//add an [[admin]] link if configured
		if ($AddAdmin == 'yes')
		    $RowNav .= "<a class=\"$LinkClas\" href=\"".$CONF['AdminURL']."\" title=\"[[admin]] area\">Admin</a>";
 
		//print out row nav
		$RowNav .= $PosNav;
		echo $RowNav;
 
		//bye bye
		mysql_free_result($categories);
 
    }
 
}
?>
nprownavphp.txt · Last modified: 2006/07/05 13:03 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki