Now I want to present my navigation with more than one submenu. The vlibTemplate.php is in the same directory as the nqvi.php
The navi.php
include(vlibTemplate.php);
$arrNavigation] = array("naviLinkName" => "Navi_1", "link" => "navi_1.php");
$arrNavigation] = array("naviLinkName" => "Navi_2", "link" => "navi_2.php");
$arrNavigation] = array("naviLinkName" => "Navi_3", "link" => "navi_3.php",
"subNavi" => array(
array("naviLinkName" => "Navi_3_1", "link" => "navi_3_1.php"),
array("naviLinkName" => "Navi_3_2", "link" => "navi_3_2.php"),
array("naviLinkName" => "Navi_3_3", "link" => "navi_3_3.php"),
array("naviLinkName" => "Navi_3_4", "link" => "navi_3_4.php"),
array("naviLinkName" => "Navi_3_5", "link" => "navi_3_5.php")));
$arrNavigation] = array("naviLinkName" => "Navi_4", "link" => "navi_4.php");
$arrNavi = array();
foreach($arrNavigation as $arrNavigationData) {
$arrNavi[$i]["link"] = $arrNavigationData["link"];
$arrNavi[$i]["naviLinkName"] = $arrNavigationData["naviLinkName"];
if (true === isset($arrNavigationData["subNavi"])) {
foreach($arrNavigationData["subNavi"] as $intSubNavigationIndex => $arrSubNavigationData){
$arrSubNavi] = $arrSubNavigationData;
}
$arrNavi[$i]["subNavi"] = $arrSubNavi;
$arrNavi[$i]["showSubNavigation"] = 1;
} else {
$arrNavi[$i]["showSubNavigation"] = 0;
}
$i++;
}
$template = new vlibTemplate (index.html);
$template -> setloop ("navi",$arrNavi);
$template -> pparse();
The index.html:
<ul>
<tmpl_loop name=navi>
<li>
<tmpl_if name=showSubNavigation>
<a href="{tmpl_var name=link}">{tmpl_var name="naviLinkName"}</a>
<ul">
<tmpl_loop name=subNavi>
<li><a href="{tmpl_var name=link}">{tmpl_var name="naviLinkName"}</a></li>
</tmpl_loop>
</ul>
<tmpl_else>
<a href="{tmpl_var name=link}">{tmpl_var name="naviLinkName"}</a>
</tmpl_if>
</li>
</tmpl_loop>
</ul>
Sorry for not having the time neither to test this script nor to write the CSS.
I would be glad about feedback.
best regards
Eike