[phplib] Nested Menus with PHPLIB + Template From: Jens Benecke (jens <email protected>)
Date: 06/20/01

Hi,

is it possible that you cannot put set_block()s with the same variable name
into e.g. while() loops?

When the code below goes into the second main loop, I get "Template Error:
loadfile: subitem is not a valid handle. Halted." when it was supposed to
create the second sub-menu (i.e. the entry "Drucker").

Thanks!

I have a menu.html included into a big main.html (inclusion works)
---------------------------------------------------------------------------
<table border=0 width="100%" cellpadding=0 cellspacing=0>
 
<!-- BEGIN item -->
    <tr><td colspan=2 class={CLS}><br><big><b><a href="{URL}">{TEXT}</a></b></td></tr>
    <!-- BEGIN subitem -->
    <tr><td class={SUBCLS} width=5>-&nbsp;</td>
        <td class={SUBCLS}><a href="{SUBURL}">{SUBTEXT}</a></td></tr>
    <!-- END subitem -->
<!-- END item -->

</table>
---------------------------------------------------------------------------

and the content
---------------------------------------------------------------------------
    var $menu = array(
        "Hauptseite" => "index.php",
        "Dokumente" => array(
            "Who's Who" => "doc-whoswho.php",
            "Benutzungsordnung" => "doc-bordnung.php",
            "FAQ" => "doc-faq.php",
            "Computereinrichtung" => "doc_einrichtung/"
        ),
        "Netzwerkdienste" => array(
            "Drucker" => "netz-drucker.php",
            "Scanner" => "netz-scanner.php",
            "Mail + News" => "netz-mail+news.php",
            "FTP + Samba" => "netz-ftp+samba.php",
            "Telnet + SSH" => "netz-shell.php",
            "Proxy-Server" => "netz-proxy.php"
        ),
 
        "Administration" => array(
            "Benutzer" => "admin.php",
            "Datenbank" => "/myadmin/",
            "Mailinglisten" => "/cgi-bin/mailman/listinfo",
        ),
 
        "Eigene Einstellungen" => "user.php",
 
        "Gimmicks" => array(
            "Web Mail" => "/squirrel/",
            "Netzwerksuche" => "/femfind/",
        ),
    );
---------------------------------------------------------------------------

and I try to fill it via
---------------------------------------------------------------------------
        while(list($e,$v) = each($this->menu)) {
 
            if(is_array($v)) { # do submenus exist?
 
                error_log(" v=".basename($v), 0);
                $class = (basename($GLOBALS[REQUEST_URI]) == basename($v)) ? "active" : "inactive"; # just layout
 
                $this->set_var("TEXT", $e);

                # parse out sub-block
                $this->set_block("items", "subitem", "subitems");
                while(list($ee, $vv) = each($v)) {
                    error_log(" vv=".basename($vv), 0);
                    $this->set_var(array(
                        SUBCLS => $class,
                        SUBURL => $vv,
                        SUBTEXT => $ee,
                    ));
                    $this->parse("subitems", "subitem", true);
                }
 
            } else {
 
                $this->set_var(array(
                    CLS => $class,
                    TEXT => "<a href=\"$v\">$e</a>",
                ));
 
            }

            $this->parse("items", "item", true);
        }

---------------------------------------------------------------------------

-- 
Jens Benecke     No Linux user has a 'Microsoft free system'. 'make config'
                 in the kernel configuration was originally written by a MS
		 employee.
http://www.hitchhikers.de/ - Die kostenlose Mitfahrzentrale für ganz Europa

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>