Treemenu no phpBB

31 agosto, 2006 Sem comentários »

Bom hoje o Grejão da Slacklife comentou que queria utilizar um treemenu em um forum dele, onde esse treemenu seria um menu com as categorias dos forums.

Olhando no goolge eu achei esse código em javascript que cria a Treemenu com vários exemplos e funcionabilidades http://www.treemenu.net fiz um pequeno código no phpBB baseando no search.php para que fizesse um array com os forums separados por categoria, depois criei o treemenu utilizando o javascript.

clique para ver o conteúdo completo para ver o código.

PHP:
  1. <?php
  2.  
  3. define('IN_PHPBB', true);
  4. $phpbb_root_path = './';
  5. include($phpbb_root_path . 'extension.inc');
  6. include($phpbb_root_path . 'common.'.$phpEx);
  7. include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
  8.  
  9. $userdata = session_pagestart($user_ip, PAGE_SEARCH);
  10. init_userprefs($userdata);
  11.  
  12. $sql = "SELECT c.cat_title, c.cat_id, f.forum_name, f.forum_id
  13. FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
  14. WHERE f.cat_id = c.cat_id
  15. ORDER BY c.cat_order, f.forum_order";
  16. $result = $db->sql_query($sql);
  17. if ( !$result )
  18. {
  19. message_die(GENERAL_ERROR, 'Could not obtain forum_name/forum_id', '', __LINE__, __FILE__, $sql);
  20. }
  21.  
  22. $is_auth_ary = auth(AUTH_READ, AUTH_LIST_ALL, $userdata);
  23.  
  24. $s_forums = '';
  25. while( $row = $db->sql_fetchrow($result) )
  26. {
  27. if ( $is_auth_ary[$row['forum_id']]['auth_read'] )
  28. {
  29. if ( empty($xforum[$row['cat_id']][nome]) )
  30. {
  31. $xforum[$row['cat_id']][nome] = $row['cat_title'];
  32. }
  33.  
  34. $xforum[$row['cat_id']][sub][$row['forum_id']]=$row['forum_name'];
  35.  
  36. }
  37. }
  38.  
  39. ?>

HTML:
  1.  
  2.  
  3. <title>Frameless JavaScript Tree</title>
  4.  
  5. <!-- SECTION 1 -->
  6. /* styles for the tree */
  7. SPAN.TreeviewSpanArea A {
  8. font-size: 10pt;
  9. font-family: verdana,helvetica;
  10. text-decoration: none;
  11. color: black
  12. }
  13. SPAN.TreeviewSpanArea A:hover {
  14. color: '#820082';
  15. }
  16. /* rest of the document */
  17. BODY {background-color: white}
  18. TD {
  19. font-size: 10pt;
  20. font-family: verdana,helvetica;
  21. }
  22. </style>
  23.  
  24.  
  25.  
  26. <!-- SECTION 3: These four scripts define the tree, do not remove-->
  27. <script xsrc="treemenu/ua.js"></script>
  28. <script xsrc="treemenu/ftiens4.js"></script>
  29.  
  30. USETEXTLINKS = 1
  31. STARTALLOPEN = 0
  32. USEFRAMES = 0
  33. USEICONS = 0
  34. WRAPTEXT = 1
  35. PRESERVESTATE = 1
  36. ICONPATH = "treemenu/"
  37.  
  38.  
  39. foldersTree = gFld("<b>Forum KM</b>", 'javascript:alert("teste");')

PHP:
  1. <?
  2. foreach($xforum as $x => $v) {
  3.  
  4. echo 'aux1 = insFld(foldersTree, gFld("'.$v[nome].'", "javascript:undefined"))' . "\n";
  5. foreach($v[sub] as $z => $t) {
  6. echo 'aux2 = insFld(aux1, gFld("'.$t.'", \'javascript:alert("Abrir Forum ('.$z.')")\'))' . "\n";
  7.  
  8. }
  9.  
  10. }
  11.  
  12. ?>

HTML:
  1. </script>
  2. </head>
  3.  
  4.  
  5. <!-- SECTION 4: Change the body tag to fit your site -->
  6. <body bgcolor=white leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" onResize="if (navigator.family == 'nn4') window.location.reload()">
  7.  
  8.  
  9. <!-- SECTION 6: Build the tree. -->
  10.  
  11. <!-- By making any changes to this code you are violating your user agreement.
  12. Corporate users or any others that want to remove the link should check
  13. the online FAQ for instructions on how to obtain a version without the link -->
  14. <!-- Removing this link will make the script stop from working -->
  15. <table border=0>
  16. <td><font size=-2><a style="font-size:7pt;text-decoration:none;color:silver" xhref="http://www.treemenu.net/" target=_blank>JavaScript Tree Menu</a></font></td>
  17. </tr>
  18. </table>
  19. <span class=TreeviewSpanArea>
  20. <script>initializeDocument()</script>
  21. A tree for site navigation will open here if you enable JavaScript in your browser.
  22. </noscript>
  23. </span>
  24.  
  25. </body>
  26. </html>

Post a Comment