suckerMenu for Indexhibit


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php if (!defined('SITE')) exit('No direct script access allowed');
  2. /**
  3. *
  4. * flat Suckerfish menu
  5. *
  6. * @version" 0.1
  7. * @author: Vaska
  8. * @author: orionrush
  9. * @use: 1 - Save this clip as plugin.suckerMenu.php and place it in ndxz-studio/site/plugin
  10. * @use: 2 -in your site template (ndxz-studio/site/your-template-name/index.php) replace <plug:front_index /> with <plug:suckerMenu />
  11. * @inspiration: http://www.htmldog.com/articles/suckerfish/dropdowns/
  12. *
  13. **/
  14.  
  15. function suckerMenu()
  16. {
  17. $OBJ =& get_instance();
  18. global $rs;
  19.  
  20. $pages = $OBJ->db->fetchArray("SELECT id, title, url,
  21. section, sec_desc, sec_disp, year, secid
  22. FROM ".PX."objects, ".PX."sections
  23. WHERE status = '1'
  24. AND hidden != '1'
  25. AND section_id = secid
  26. ORDER BY sec_ord ASC, ord ASC");
  27.  
  28. if (!$pages) return 'Error with pages query';
  29.  
  30. foreach($pages as $reord)
  31. {
  32. $order[$reord['sec_desc']][] = array(
  33. 'id' => $reord['id'],
  34. 'title' => $reord['title'],
  35. 'url' => $reord['url'],
  36. 'year' => $reord['year'],
  37. 'secid' => $reord['secid'],
  38. 'disp' => $reord['sec_disp']);
  39. }
  40.  
  41. $s = '';
  42. $s .= "<ul id='suckerNav'>\n";
  43. foreach($order as $key => $out)
  44. {
  45.  
  46. if ($out[0]['disp'] == 1) $s .= "<li class='section-title'>" . $key . "\n";
  47.  
  48. //need to insert if else for cases where Display Section Title is off, where by we need a new ul section for the title-less section
  49. if ($out[0]['disp'] != 1) $s .= "<li>\n";
  50. $s .= "<ul>\n";
  51. foreach($out as $page)
  52.  
  53.  
  54. //adds the class noSectTitle to the first li element in ul sections where the user has turned off 'Dispaly Section Title'
  55. if ($out[0]['disp'] != 1){
  56. $active = ($rs['id'] == $page['id']) ? " class='active noSectTitle'" : " class='noSectTitle'";
  57. $s .= "<li$active><a href='" . BASEURL . ndxz_rewriter($page['url']) . "' onclick=\"do_click();\">" . $page['title'] . "</a></li>\n";
  58. }
  59. else {
  60. {
  61. $active = ($rs['id'] == $page['id']) ? " class='active'" : '';
  62. $s .= "<li$active><a href='" . BASEURL . ndxz_rewriter($page['url']) . "' onclick=\"do_click();\">" . $page['title'] . "</a></li>\n";
  63. }
  64. }
  65.  
  66. $s .= "</ul>\n</li>\n";
  67.  
  68. }
  69. $s .= "</ul>\n";
  70.  
  71.  
  72.  
  73. return $s;
  74. }
  75.  
  76. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.