NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Collapsable menu in php

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 01-05-2005, 02:03 PM THREAD STARTER               #1 (permalink)
Account Suspended
 
axilant's Avatar
Join Date: May 2004
Location: /etc/passwd
Posts: 2,178
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
 

Member of the Month
July 2005

Collapsable menu in php


its a class:

I did not program this my self, i found it somewhere, and i fixed a bug...

PHP Code:
<?
class menu {
    var 
$name;
    var 
$items;
    var 
$open;
    var 
$closed;
    var 
$indent;

    function 
menu($name,
                  
$open '(-)',
                  
$closed '(+)',
                  
$indent '&nbsp; &nbsp; &nbsp; '
                 
)
    {
        
$this->items  = array();
        
$this->name   $name;
        
$this->open   $open;
        
$this->closed $closed;
        
$this->indent $indent;
    }

    function 
add($name$href ""$target "") {
        
$n count($this->items);

        if (
is_object($name)) {
            
$this->items[$n] = $name;
        } else {
            
$this->items[$n]['name'] = $name;
            
$this->items[$n]['href'] = $href;
            
$this->items[$n]['target'] = $target;
        }
    }

    function 
show($nest 0) {
        
$urlname strtr($this->name' ''_');
        
$indent '';
        global $
$urlname;
        global 
$PHP_SELF;
        global 
$QUERY_STRING;

        if (
$nest) {
            
$indent str_repeat($this->indent$nest);
????: NamePros.com http://www.namepros.com/code/63394-collapsable-menu-in-php.html
        }

        if (isset($
$urlname)) {
            
printf('%s<a href="%s?%s">%s</a><br>',
                   
$indent $this->open,
                   
$PHP_SELF,
                   
ereg_replace("{$urlname}=&"''$QUERY_STRING),
                   
$this->name);
            echo 
"";

            while (list(,
$item) = each($this->items)) {
                if (
is_object($item)) {
                    
$item->show($nest 1);
                } else {
                    
printf('%s<a href="%s"%s>%s</a><br>',
                           
$indent $this->indent,
????: NamePros.com http://www.namepros.com/showthread.php?t=63394
                           
$item['href'],
                           (!empty(
$item['target']) ? ' target="' .
                                                      
$item['target'] . '"'
                                                    
''),
                           
$item['name']);
                    echo 
"";
                }
            }
        } else {
            
printf('%s<a href="%s?%s=&%s">%s</a><br>',
                   
$indent $this->closed,
                   
$PHP_SELF,
                   
$urlname$QUERY_STRING,
                   
$this->name);
            echo 
"";
        }
    }
}

$submenu = new menu('Sub Menu');
$submenu->add('Sub Item 1''link.html''_new');
$submenu->add('Sub Item 2''link.html');

$main = new menu('Main');
$main->add('Main Item 1''link.html');
$main->add('Main Item 2''link.html');
$main->add($submenu);
$main->add('Main Item 3''link.html');

$second = new menu('Secondary Menu');
$second->add('Secondary Item 1''link.html');
$second->add('Secondary Item 2''link.html');

$main->show();
$second->show();
?>

if you need any help pm me or email me, http://romazom.com/support.php :) well i have to get back to programming
axilant is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 07:31 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger