Cibiņš Posted June 6, 2012 Report Share Posted June 6, 2012 (edited) Īsti nesaprotu..man ir rekursijas funkcija kas veido vairāklīmeņa izvēlnes. function sitemap2($pid2){ $sql2="SELECT * FROM pg_menu WHERE parent_id=".intval($pid2)." AND status = '1' ORDER BY position ASC;"; $res2=mysql_query($sql2); if(mysql_num_rows($res2)<1){ return ''; } $s2='<ul id="MenuBar1" class="MenuBarVertical">'; while($row2=mysql_fetch_object($res2)){ $s2.='<li>'; $s2.='<a href="#">'; if($_GET['lang'] == 'ru'){ $s2.= $row2->desc_ru; } elseif($_GET['lang'] == 'en'){ $s2.= $row2->desc_en; } else { $s2.= $row2->desc_lv; } $s2.='</a>'; $s2.=sitemap2($row2->id); $s2.='</li>'; } $s2.='</ul>'; return $s2; } ?> kas atgriež <pre id="line1"><ul id="MenuBar1" class="MenuBarVertical"> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 1</a> <ul></pre><pre id="line21"> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 1.1</a></li> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 1.2</a></li> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 1.3</a></li> </ul> </li> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 2</a></li> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 3</a> <ul> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 3.1</a> <ul> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 3.1.1</a></li> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 3.1.2</a></li> </ul> </li></pre><pre id="line28"> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 3.2</a></li> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 3.3</a></li> </ul> </li> <li><a href="[url="view-source:http://localhost:81/dropdown/#"]#[/url]">Item 4</a></li></ul></pre> Kā panākt lai rekursija pieliek klasi class="MenuBarItemSubmenu" pie pirmā hrefa, kam seko apakšlīmenis? Tipa lai <ul id="MenuBar1" class="MenuBarVertical"> <li><a href="#">Item 1</a> <ul> <li><a href="#">Item 1.1</a></li> <li><a href="#">Item 1.2</a></li> <li><a href="#">Item 1.3</a></li> </ul> </li> <li><a href="#">Item 2</a></li> <li><a href="#">Item 3</a> <ul> <li><a href="#">Item 3.1</a></li> <li><a href="#">Item 3.2</a> <ul> <li><a href="#">Item 3.2.1</a></li> <li><a href="#">Item 3.2.2</a></li> <li><a href="#">Item 3.2.3</a></li> </ul> </li> <li><a href="#">Item 3.3</a></li> </ul> </li> <li><a href="#">Item 4</a></li> </ul> nostrādā kā <ul id="MenuBar1" class="MenuBarVertical"> <li><a class="MenuBarItemSubmenu" href="#">Item 1</a> <ul> <li><a href="#">Item 1.1</a></li> <li><a href="#">Item 1.2</a></li> <li><a href="#">Item 1.3</a></li> </ul> </li> <li><a href="#">Item 2</a></li> <li><a class="MenuBarItemSubmenu" href="#">Item 3</a> <ul> <li><a href="#">Item 3.1</a></li> <li><a class="MenuBarItemSubmenu" href="#">Item 3.2</a> <ul> <li><a href="#">Item 3.2.1</a></li> <li><a href="#">Item 3.2.2</a></li> <li><a href="#">Item 3.2.3</a></li> </ul> </li> <li><a href="#">Item 3.3</a></li> </ul> </li> <li><a href="#">Item 4</a></li> </ul> Edited June 6, 2012 by Cibiņš Link to comment Share on other sites More sharing options...
Cibiņš Posted June 6, 2012 Author Report Share Posted June 6, 2012 Aa nē nevajag panācu ar javascriptu :D Link to comment Share on other sites More sharing options...
daGrevis Posted June 7, 2012 Report Share Posted June 7, 2012 TU VARI TĀ BEIGT DARĪT?! Taisīt topiku, pats artisināt un aizvērt?!! Link to comment Share on other sites More sharing options...
Recommended Posts