Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. <select>
  2. <option value="1">Category1</option>
  3. <option value="4">::SubCategory2</option>
  4. <option value="2">::SubCategory1</option>
  5. <option value="3">::::SubSubCategory</option>
  6. <option></option>
  7. </select>
  8.  
  9. Array
  10. (
  11. [0] => Array
  12. (
  13. [id] => 1
  14. [name] => Category1
  15. [parent] => 0
  16. [children] => Array
  17. (
  18. [0] => Array
  19. (
  20. [id] => 4
  21. [name] => SubCategory2
  22. [parent] => 1
  23. [children] => Array
  24. (
  25. )
  26.  
  27. )
  28.  
  29. [1] => Array
  30. (
  31. [id] => 2
  32. [name] => SubCategory1
  33. [parent] => 1
  34. [children] => Array
  35. (
  36. [0] => Array
  37. (
  38. [id] => 3
  39. [name] => SubSubCategory
  40. [parent] => 2
  41. [children] => Array
  42. (
  43. )
  44.  
  45. )
  46.  
  47. )
  48.  
  49. )
  50.  
  51. )
  52.  
  53. )
  54. )
  55.  
  56. function GenerateSet($nav, $tabs = "") {
  57. $html = !strlen($tabs) ?
  58. "n".$tabs.'<ul class="categories">'."n" :
  59. "n".$tabs.'<ul>'."n";
  60.  
  61. foreach($nav as $page) {
  62.  
  63. $html .= $tabs." ".'<li id="cat-'.$page['id'].'">';
  64. $html .= ' <a href="#">
  65. <span class="linker">
  66. <span class="title">'.$page['name'].'</span>
  67. </span>
  68. </a>';
  69.  
  70. if(isset($page['children'][0])) {
  71. $html .= $this->GenerateSet($page['children'], $tabs." ");
  72. }
  73. $html .= '</li>'."n";
  74. }
  75. $html .= $tabs.'</ul>'."n";
  76.  
  77. return $html;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement