Why not register?


Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]

Author Message
PostPosted: Fri Oct 24, 2003 12:01 pm  Post subject: Main page PHP Tree Code (Needed Please!)
Reply with quote
User avatar
Offline

The Devil, Probably
Joined: Mon Sep 08, 2003 6:32 pm
Posts: 2153
Location: H.H.A.H. I.R.C. =STR= Lair
Hi, Spud.

Was wondering if you would be so very kind as to give me the code you use on the main sites front page to do a directory tree of links?

It's for my work, as starting monday I will be developing a website for a department and from what I've seen of the content I'm gona need to use a directory tree structure to be able to hide/show links to pages within the site.

If not, then this weekend I'll probably figure it out, did a google and found some scripts on phpbuilder/hotscripts etc, but what you got on the main page is ideal for my pupose and could save me some time.

Thanks either way, and i know your busy so don't worry about it if it's a hassle :wink:

_________________
Image
"Small-time Rippers, Finding the Need and Filling it in 2004"


Top
 Profile  
PostPosted: Sat Oct 25, 2003 12:13 am  Post subject:
Reply with quote
User avatar
Offline

Site Admin
Joined: Sat Nov 02, 2002 1:35 am
Posts: 19753
Location: En EspaƱa
Hope you know what code to extract. I'd say it's the latter code, but it's all php

Code:
<?php
//*****************************************************************//
//           Integrated as Tree Menu block to PHP-Nuke            //
//                                                                 //
//                 Turan ASLAN <t.aslan@chello.nl>                 //
//                http://members.lycos.nl/sila2003/                //
//*****************************************************************//

if (eregi("block-Tree_Menu.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}
global $cookie, $prefix, $currentlang, $dbi;

if(file_exists("/blocks/tree_menu/language/lang-$currentlang.js")) {
 include("/blocks/tree_menu/language/lang-$currentlang.js");
}
$content  =  "<script language=\"JavaScript\" src=\"blocks/tree_menu/tree.js\"></script>";
$content  .= "<script language=\"JavaScript\" src=\"blocks/tree_menu/language/lang-$currentlang.js\"></script>";
$content  .= "<script language=\"JavaScript\" src=\"blocks/tree_menu/tree_tpl.js\"></script>";
$content  .= "<script language=\"JavaScript\">";
$content  .= "    new tree (TREE_ITEMS, tree_tpl);";
$content  .= "</script>";
?>


Code:
// Title: Tigra Tree
// Description: See the demo at url
// URL: http://www.softcomplex.com/products/tigra_menu_tree/
// Version: 1.0
// Date: 07-20-2002 (mm-dd-yyyy)
// Contact: feedback@softcomplex.com (specify product title in the subject)
//*****************************************************************//
//              Integrated as Tree Menu block to PHP-Nuke            //
// Change nothing after this line! Otherwise the tree menu will    //
// not work.                                                       //
//                                                                 //
// Turan ASLAN <t.aslan@chello.nl>                                 //
// http://members.lycos.nl/sila2003/                               //
//*****************************************************************//

function tree (a_items, a_template) {

    this.a_tpl      = a_template;
   this.a_config   = a_items;
  this.o_root     = this;
 this.a_index    = [];
   this.o_selected = null;
 this.n_depth    = -1;
   
    this.toggle = function (n_id) {    var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened) };
   this.select = function (n_id) { return this.a_index[n_id].select(); };
    this.mout   = function (n_id) { this.a_index[n_id].upstatus(true) };
  this.mover  = function (n_id) { this.a_index[n_id].upstatus() };

  this.a_children = [];
   for (var i = 0; i < a_items.length; i++)
     new tree_item(this, i);

 this.n_id = trees.length;
   trees[this.n_id] = this;
   
    for (var i = 0; i < this.a_children.length; i++) {
      document.write(this.a_children[i].init());
      this.a_children[i].open();
  }
}

function tree_item (o_parent, n_order) {

   this.n_depth  = o_parent.n_depth + 1;
   this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];
    if (!this.a_config) return;

 this.o_root    = o_parent.o_root;
   this.o_parent  = o_parent;
  this.n_order   = n_order;
   this.b_opened  = !this.n_depth;

 this.n_id = this.o_root.a_index.length;
 this.o_root.a_index[this.n_id] = this;
  o_parent.a_children[n_order] = this;

    this.a_children = [];
   for (var i = 0; i < this.a_config.length - 2; i++)
       new tree_item(this, i);

 this.get_icon = item_get_icon;
  this.open     = item_open;
  this.select   = item_select;
    this.init     = item_init;
  this.upstatus = item_upstatus;
  this.is_last  = function () { return this.n_order == this.o_parent.a_children.length - 1 };
}

function item_open (b_close) {
  var o_idiv = get_element('i_div' + this.n_id);
    if (!o_idiv) return;
   
    if (!o_idiv.innerHTML) {
       var a_children = [];
        for (var i = 0; i < this.a_children.length; i++)
         a_children[i]= this.a_children[i].init();
       o_idiv.innerHTML = a_children.join('');
   }
  o_idiv.style.display = (b_close ? 'none' : 'block');
   
    this.b_opened = !b_close;
   var o_jicon = document.images['j_img' + this.n_id],
       o_iicon = document.images['i_img' + this.n_id];
   if (o_jicon) o_jicon.src = this.get_icon(true);
 if (o_iicon) o_iicon.src = this.get_icon();
 this.upstatus();
}

function item_select (b_deselect) {
  if (!b_deselect) {
     var o_olditem = this.o_root.o_selected;
     this.o_root.o_selected = this;
      if (o_olditem) o_olditem.select(true);
  }
  var o_iicon = document.images['i_img' + this.n_id];
   if (o_iicon) o_iicon.src = this.get_icon();
 get_element('i_txt' + this.n_id).style.fontWeight = b_deselect ? 'normal' : 'bold';
   
    this.upstatus();
    return Boolean(this.a_config[1]);
}

function item_upstatus (b_clear) {
  window.setTimeout('window.status="' + (b_clear ? '' : this.a_config[0] + (this.a_config[1] ? ' ('+ this.a_config[1] + ')' : '')) + '"', 10);
}

function item_init () {
    var a_offset = [],
      o_current_item = this.o_parent;
 for (var i = this.n_depth; i > 1; i--) {
        a_offset[i] = '<img src="' + this.o_root.a_tpl[o_current_item.is_last() ? 'icon_e' : 'icon_l'] + '" border="0" align="absbottom">';
     o_current_item = o_current_item.o_parent;
   }
  return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap>' + (this.n_depth ? a_offset.join('') + (this.a_children.length ? '<a href="javascript: trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')"><img src="' + this.get_icon(true) + '" border="0" align="absbottom" name="j_img' + this.n_id + '"></a>' : '<img src="' + this.get_icon(true) + '" border="0" align="absbottom">') : '') + '<a href="' + this.a_config[1] + '" target="' + this.o_root.a_tpl['target'] + '" onclick="return trees[' + this.o_root.n_id + '].select(' + this.n_id + ')" ondblclick="trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')" class="t' + this.o_root.n_id + 'i" id="i_txt' + this.n_id + '"><img src="' + this.get_icon() + '" border="0" align="absbottom" name="i_img' + this.n_id + '" class="t' + this.o_root.n_id + 'im">' + this.a_config[0] + '</a></td></tr></table>' + (this.a_children.length ? '<div id="i_div' + this.n_id + '" style="display:none"></div>' : '');
}

function item_get_icon (b_junction) {
 return this.o_root.a_tpl['icon_' + ((this.n_depth ? 0 : 32) + (this.a_children.length ? 16 : 0) + (this.a_children.length && this.b_opened ? 8 : 0) + (!b_junction && this.o_root.o_selected == this ? 4 : 0) + (b_junction ? 2 : 0) + (b_junction && this.is_last() ? 1 : 0))];
}

var trees = [];
get_element = document.all ?
 function (s_id) { return document.all[s_id] } :
   function (s_id) { return document.getElementById(s_id) };


Code:
/*
    Feel free to use your custom icons for the tree. Make sure they are all of the same size.
   User icons collections are welcome, we'll publish them giving all regards.
*/
//*****************************************************************//
//              Integrated as Tree Menu block to PHP-Nuke            //
//                                                                 //
//                 Turan ASLAN <t.aslan@chello.nl>                 //
//                http://members.lycos.nl/sila2003/                //
//*****************************************************************//

var tree_tpl = {
   'target'  : '_self',    // name of the frame links will be opened in
                            // other possible values are: _blank, _parent, _search, _self and _top

  'icon_e'  : 'blocks/tree_menu/icons/empty.gif', // empty image
  'icon_l'  : 'blocks/tree_menu/icons/line.gif',  // vertical line
   
    'icon_48' : 'blocks/tree_menu/icons/base.gif',   // root icon normal
    'icon_52' : 'blocks/tree_menu/icons/base.gif',   // root icon selected
  'icon_56' : 'blocks/tree_menu/icons/base.gif',   // root icon opened
    'icon_60' : 'blocks/tree_menu/icons/base.gif',   // root icon selected
 
    'icon_16' : 'blocks/tree_menu/icons/folder.gif', // node icon normal
    'icon_20' : 'blocks/tree_menu/icons/folderopen.gif', // node icon selected
  'icon_24' : 'blocks/tree_menu/icons/folder.gif', // node icon opened
    'icon_28' : 'blocks/tree_menu/icons/folderopen.gif', // node icon selected opened

   'icon_0'  : 'blocks/tree_menu/icons/page.gif', // leaf icon normal
  'icon_4'  : 'blocks/tree_menu/icons/page.gif', // leaf icon selected
    'icon_8'  : 'blocks/tree_menu/icons/page.gif', // leaf icon opened
  'icon_12' : 'blocks/tree_menu/icons/page.gif', // leaf icon selected
   
    'icon_2'  : 'blocks/tree_menu/icons/joinbottom.gif', // junction for leaf
   'icon_3'  : 'blocks/tree_menu/icons/join.gif',       // junction for last leaf
  'icon_18' : 'blocks/tree_menu/icons/plusbottom.gif', // junction for closed node
    'icon_19' : 'blocks/tree_menu/icons/plus.gif',       // junctioin for last closed node
  'icon_26' : 'blocks/tree_menu/icons/minusbottom.gif',// junction for opened node
    'icon_27' : 'blocks/tree_menu/icons/minus.gif'       // junctioin for last opended node
};


Code:
//*****************************************************************//
//              Integrated as Tree Menu block to PHP-Nuke            //
//                                                                 //
//                 Turan ASLAN <t.aslan@chello.nl>                 //
//                http://members.lycos.nl/sila2003/                //
//*****************************************************************//

var TREE_ITEMS = [
  ['Home', 'index.php',
       ['Movie Links', 'modules.php?name=Reviews',
         ['Add a movie', 'modules.php?name=Reviews&rop=write_review'],
           ['misc', 'http://forum.dead-donkey.com/viewtopic.php?t=506'],
           ['A', 'modules.php?name=Reviews&rop=A'],
            ['B', 'modules.php?name=Reviews&rop=B'],
            ['C', 'modules.php?name=Reviews&rop=C'],
            ['D', 'modules.php?name=Reviews&rop=D'],
            ['E', 'modules.php?name=Reviews&rop=E'],
            ['F', 'modules.php?name=Reviews&rop=F'],
            ['G', 'modules.php?name=Reviews&rop=G'],
            ['H', 'modules.php?name=Reviews&rop=H'],
            ['I', 'modules.php?name=Reviews&rop=I'],
            ['J', 'modules.php?name=Reviews&rop=J'],
            ['K', 'modules.php?name=Reviews&rop=K'],
            ['L', 'modules.php?name=Reviews&rop=L'],
            ['M', 'modules.php?name=Reviews&rop=M'],
            ['N', 'modules.php?name=Reviews&rop=N'],
            ['O', 'modules.php?name=Reviews&rop=O'],
            ['P', 'modules.php?name=Reviews&rop=P'],
            ['Q', 'modules.php?name=Reviews&rop=Q'],
            ['R', 'modules.php?name=Reviews&rop=R'],
            ['S', 'modules.php?name=Reviews&rop=S'],
            ['T', 'modules.php?name=Reviews&rop=T'],
            ['U', 'modules.php?name=Reviews&rop=U'],
            ['V', 'modules.php?name=Reviews&rop=V'],
            ['W', 'modules.php?name=Reviews&rop=W'],
            ['X', 'modules.php?name=Reviews&rop=X'],
            ['Y', 'modules.php?name=Reviews&rop=Y'],
            ['Z', 'modules.php?name=Reviews&rop=Z'],
            ['0', 'modules.php?name=Reviews&rop=0'],
            ['1', 'modules.php?name=Reviews&rop=1'],
            ['2', 'modules.php?name=Reviews&rop=2'],
            ['3', 'modules.php?name=Reviews&rop=3'],
            ['4', 'modules.php?name=Reviews&rop=4'],
            ['5', 'modules.php?name=Reviews&rop=5'],
            ['6', 'modules.php?name=Reviews&rop=6'],
            ['7', 'modules.php?name=Reviews&rop=7'],
            ['8', 'modules.php?name=Reviews&rop=8'],
            ['9', 'modules.php?name=Reviews&rop=9'],
        ],
      ['Series Links', 'modules.php?name=Reviews2',
           ['Add a series', 'modules.php?name=Reviews2&rop=write_review2'],
            ['A', 'modules.php?name=Reviews2&rop=A'],
           ['B', 'modules.php?name=Reviews2&rop=B'],
           ['C', 'modules.php?name=Reviews2&rop=C'],
           ['D', 'modules.php?name=Reviews2&rop=D'],
           ['E', 'modules.php?name=Reviews2&rop=E'],
           ['F', 'modules.php?name=Reviews2&rop=F'],
           ['G', 'modules.php?name=Reviews2&rop=G'],
           ['H', 'modules.php?name=Reviews2&rop=H'],
           ['I', 'modules.php?name=Reviews2&rop=I'],
           ['J', 'modules.php?name=Reviews2&rop=J'],
           ['K', 'modules.php?name=Reviews2&rop=K'],
           ['L', 'modules.php?name=Reviews2&rop=L'],
           ['M', 'modules.php?name=Reviews2&rop=M'],
           ['N', 'modules.php?name=Reviews2&rop=N'],
           ['O', 'modules.php?name=Reviews2&rop=O'],
           ['P', 'modules.php?name=Reviews2&rop=P'],
           ['Q', 'modules.php?name=Reviews2&rop=Q'],
           ['R', 'modules.php?name=Reviews2&rop=R'],
           ['S', 'modules.php?name=Reviews2&rop=S'],
           ['T', 'modules.php?name=Reviews2&rop=T'],
           ['U', 'modules.php?name=Reviews2&rop=U'],
           ['V', 'modules.php?name=Reviews2&rop=V'],
           ['W', 'modules.php?name=Reviews2&rop=W'],
           ['X', 'modules.php?name=Reviews2&rop=X'],
           ['Y', 'modules.php?name=Reviews2&rop=Y'],
           ['Z', 'modules.php?name=Reviews2&rop=Z'],
           ['0', 'modules.php?name=Reviews2&rop=0'],
           ['1', 'modules.php?name=Reviews2&rop=1'],
           ['2', 'modules.php?name=Reviews2&rop=2'],
           ['3', 'modules.php?name=Reviews2&rop=3'],
           ['4', 'modules.php?name=Reviews2&rop=4'],
           ['5', 'modules.php?name=Reviews2&rop=5'],
           ['6', 'modules.php?name=Reviews2&rop=6'],
           ['7', 'modules.php?name=Reviews2&rop=7'],
           ['8', 'modules.php?name=Reviews2&rop=8'],
           ['9', 'modules.php?name=Reviews2&rop=9'],
       ],
      ['Games Links',  'modules.php?name=Reviews3',
           ['Add a game', 'modules.php?name=Reviews3&rop=write_review3'],
          ['A', 'modules.php?name=Reviews3&rop=A'],
           ['B', 'modules.php?name=Reviews3&rop=B'],
           ['C', 'modules.php?name=Reviews3&rop=C'],
           ['D', 'modules.php?name=Reviews3&rop=D'],
           ['E', 'modules.php?name=Reviews3&rop=E'],
           ['F', 'modules.php?name=Reviews3&rop=F'],
           ['G', 'modules.php?name=Reviews3&rop=G'],
           ['H', 'modules.php?name=Reviews3&rop=H'],
           ['I', 'modules.php?name=Reviews3&rop=I'],
           ['J', 'modules.php?name=Reviews3&rop=J'],
           ['K', 'modules.php?name=Reviews3&rop=K'],
           ['L', 'modules.php?name=Reviews3&rop=L'],
           ['M', 'modules.php?name=Reviews3&rop=M'],
           ['N', 'modules.php?name=Reviews3&rop=N'],
           ['O', 'modules.php?name=Reviews3&rop=O'],
           ['P', 'modules.php?name=Reviews3&rop=P'],
           ['Q', 'modules.php?name=Reviews3&rop=Q'],
           ['R', 'modules.php?name=Reviews3&rop=R'],
           ['S', 'modules.php?name=Reviews3&rop=S'],
           ['T', 'modules.php?name=Reviews3&rop=T'],
           ['U', 'modules.php?name=Reviews3&rop=U'],
           ['V', 'modules.php?name=Reviews3&rop=V'],
           ['W', 'modules.php?name=Reviews3&rop=W'],
           ['X', 'modules.php?name=Reviews3&rop=X'],
           ['Y', 'modules.php?name=Reviews3&rop=Y'],
           ['Z', 'modules.php?name=Reviews3&rop=Z'],
           ['0', 'modules.php?name=Reviews3&rop=0'],
           ['1', 'modules.php?name=Reviews3&rop=1'],
           ['2', 'modules.php?name=Reviews3&rop=2'],
           ['3', 'modules.php?name=Reviews3&rop=3'],
           ['4', 'modules.php?name=Reviews3&rop=4'],
           ['5', 'modules.php?name=Reviews3&rop=5'],
           ['6', 'modules.php?name=Reviews3&rop=6'],
           ['7', 'modules.php?name=Reviews3&rop=7'],
           ['8', 'modules.php?name=Reviews3&rop=8'],
           ['9', 'modules.php?name=Reviews3&rop=9'],
       ],
      ['Forums', 'http://forum.dead-donkey.com/',
         ['Pending FrontPage', 'http://forum.dead-donkey.com/viewtopic.php?t=506'],
          ['Site Releases', 'http://forum.dead-donkey.com/viewforum.php?f=13'],
           ['Help Forum', 'http://forum.dead-donkey.com/viewforum.php?f=2'],
           ['Register', 'http://forum.dead-donkey.com/profile.php?mode=register&sid='],
            ['Forum Search', 'http://forum.dead-donkey.com/search.php'],
            ['More Releases', 'http://forum.dead-donkey.com/'],
     ],
      ['Old Site', 'http://www.dead-donkey.com/Old/horror/',
          ['Movie List', 'http://www.dead-donkey.com/Old/horror/main.htm'],
           ['Games', 'http://www.dead-donkey.com/Old/horror/games/index.htm'],
         ['TV Series', 'http://www.dead-donkey.com/Old/horror/games/index.htm'],
     ],
      ['Downloads', 'modules.php?name=Downloads',
         ['Emule', 'modules.php?name=Downloads&d_op=viewdownload&cid=2'],
            ['Edonkey', 'modules.php?name=Downloads&d_op=viewdownload&cid=3'],
          ['Codecs', 'modules.php?name=Downloads&d_op=viewdownload&cid=4'],
           ['Utilities', 'http://www.dead-donkey.com/modules.php?name=Downloads&d_op=viewdownload&cid=5'],
     ],
      ['Account', 'modules.php?name=Your_Account',
            ['Profile', 'modules.php?name=Your_Account&op=edituser'],
           ['Configure', 'modules.php?name=Your_Account&op=edithome'],
         ['Your Comments', 'modules.php?name=Your_Account&op=editcomm'],
         ['PMs', 'modules.php?name=Private_Messages'],
       ],
  ['Search', 'modules.php?name=Search'],
  ['News', 'index.php'],
  ['Submit News', 'modules.php?name=Submit_News'],
    ['News Archive', 'modules.php?name=Stories_Archive'],
   ['Site Info', 'modules.php?name=Content'],     
    ['Site FAQ', 'modules.php?name=FAQ'],
   ['Contact', 'modules.php?name=Feedback'],
   ['Surveys', 'modules.php?name=Surveys'],
    ['Top Ten', 'modules.php?name=Top'],
    ['Weblinks', 'modules.php?name=Web_Links'],
    ],
];

_________________
Mouse nipple for the win! Trackpoint or death!


Top
 Profile  
PostPosted: Sat Oct 25, 2003 12:56 am  Post subject:
Reply with quote
User avatar
Offline

Dead But Dreaming
Joined: Wed Apr 30, 2003 10:34 am
Posts: 260
Location: LV-426
it's javascript and you can save it (whole generated page) by clicking 'save page as...' (at least that is how it's called in Mozilla)
;)


Top
 Profile  
PostPosted: Sat Oct 25, 2003 11:32 am  Post subject:
Reply with quote
User avatar
Offline

The Devil, Probably
Joined: Mon Sep 08, 2003 6:32 pm
Posts: 2153
Location: H.H.A.H. I.R.C. =STR= Lair
Yeah carlos66 you're right.

Saved webpage and I got the javascript and everything.

But thanks for the code to spud, will look at it over the3 weekend and hopefully be able to get it to work.

Don't need anything flash just an expandable tree to hide/show links!

THANKS

_________________
Image
"Small-time Rippers, Finding the Need and Filling it in 2004"


Top
 Profile  
Display posts from previous:  Sort by  

All times are UTC [ DST ]

Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Frontpage / Forums / Scifi


What's blood for, if not for shedding?