By: iwan
Date: 2005-01-14
Time: 15:47
|
tree menu structures (splitted: part 2)Hi anybody,
are you have a clue how to use TBS with TREE menu, because I have to make recursive Array to create this tree menu, and I am using MySql. |
|||
By: Skrol29
Date: 2005-01-14
Time: 18:24
|
Re: tree menu structuresHi Iwan,
They are new features in TBS 2.01 that could be interesting for tree representation. What kind of tree menu are you trying to do? (<table>, <li>, ...) |
|||
By: iwan
Date: 2005-01-15
Time: 05:38
|
Re: tree menu structuresthank you very much, I got the ultratree code from
http://tourbase.ru/zink/ can I customize the output with tinybutstrong template, Tks. |
|||
By: TheIdeaMan
Date: 2005-01-15
Time: 14:43
|
Re: tree menu structuresI'd be interested in the <ul><li> tree menu system for TBS. Maybe after these are written they could be added to the Examples.
As always, Skrol29, I'm very impressed with TBS. Keep up the good work. |
|||
By: Skrol29
Date: 2005-01-16
Time: 17:21
|
Re: tree menu structuresHi Iwan,
At your page, the menu has only one sub item. How should it look with several sub items and more that 2 levels? |
|||
By: iwan
Date: 2005-01-16
Time: 17:55
|
Re: tree menu structuresHere is the coding ex:
header.php3 <? // MySQL layer if (!isset($conid)){ function dbconnect (){ $mysql=mysql_connect("host", "user", "userpass"); mysql_select_db("dbname"); return $mysql; } function dbquery ($sql){ GLOBAL $conid; $result=mysql_query($sql,$conid); return $result; } function dbfetch ($result){ if ($row=mysql_fetch_array($result)){ return $row; } else { return false; }; } function dbrows ($result){ $num=mysql_num_rows($result); return $num; }; function dbfree ($result){ mysql_free_result($result); } function dbclose ($conid){ GLOBAL $conid; mysql_close($conid); } $conid=dbconnect(); }; ?> index.php3 <? include "dblayer.php3"; // include a nice header include "header.php3"; // this function select the data from a DB and passes it to makebranch // this line: $partable[$catid][$parcat]=$name; // is used for buildparent // you may delete it if you don't use buildparent // this will save memory and time function maketree($rootcatid,$sql,$maxlevel){ // $sql is the sql statement which fetches the data // you MUST keep this order: // 1) the category ID, 2) the parent category ID, 3) the name of the category $result=dbquery($sql); while(list($catid,$parcat,$name)=dbfetch($result)){ $table[$parcat][$catid]=$name; $partable[$catid][$parcat]=$name; }; $result=buildparent($rootcatid,$table,$partable)."<br>"; $result.=makebranch($rootcatid,$table,0,$maxlevel); // please keep this notice $result.="<!--built by UltraTree v.1.1 http://www.tourbase.ru/zink/-->\n"; RETURN $result; } // this function builds the branches, // sorting them in alphabetical order function makebranch($parcat,$table,$level,$maxlevel){ $list=$table[$parcat]; asort($list); // here we do the sorting while(list($key,$val)=each($list)){ // do the indent if ($level=="0"){ $output="<img src=se.gif width=12 height=12>"; }else{ $width=($level+1)*24; $output="<img src=e.gif width=$width height=12>"; }; // the resulting HTML - feel free to change it // $level is optional $result.= "$output <a href=index.php3?catid=$key>$val</a> ($level)<br>\n"; if ((isset($table[$key])) AND (($maxlevel>$level+1) OR ($maxlevel=="0"))){ $result.= makebranch($key,$table,$level+1,$maxlevel); }; }; RETURN $result; } // this function makes the list of the parent categories // this function is optional function buildparent($catid,$table,$partable){ if ($catid!=0){ $list=$partable[$catid]; $result=each($list); $output="<a href=index.php3?catid=$result[0]>$result[1]</a> / "; $output=buildparent($result[0],$table,$partable).$output; }; RETURN $output; } // set the default category if (!isset($catid)){ $catid=0; }; // build and print the tree NOTE: $maxlevel is the maximum level, // set to 0 to show all levels $maxlevel=0; print maketree($catid,"SELECT catid,parcat,name FROM tree order by parcat",$maxlevel); ?> make.php <? include "dblayer.php3"; $sql="CREATE TABLE treetest ( catid mediumint(5) NOT NULL auto_increment, parcat mediumint(5) NOT NULL, name varchar(50) NOT NULL, UNIQUE catid (catid))"; dbquery($sql); srand((double)microtime()*1000000); for ($i=1;$i<=500;$i++){ if ($i>20){ $parcat=rand(1,100); }else{ $parcat=0; }; $sql="INSERT INTO treetest (catid,parcat,name) VALUES ('$i','$parcat','CATEG $i-$parcat')"; dbquery($sql); print "$i - $parcat<br>"; }; ?> |
|||
By: iwan
Date: 2005-01-16
Time: 18:21
|
Re: tree menu structuresPlease change table name to treetest and
this script will produces output like this (unformated) CATEG 1-0 (0) CATEG 122-1 (1) CATEG 332-1 (1) CATEG 345-1 (1) CATEG 411-1 (1) CATEG 483-1 (1) CATEG 10-0 (0) CATEG 164-10 (1) CATEG 404-10 (1) CATEG 448-10 (1) CATEG 48-10 (1) CATEG 346-48 (2) CATEG 67-10 (1) CATEG 129-67 (2) CATEG 262-67 (2) CATEG 297-67 (2) CATEG 355-67 (2) CATEG 392-67 (2) CATEG 45-67 (2) CATEG 387-45 (3) CATEG 430-45 (3) CATEG 484-45 (3) CATEG 54-45 (3) CATEG 196-54 (4) CATEG 224-54 (4) CATEG 283-54 (4) CATEG 403-54 (4) CATEG 59-67 (2) CATEG 202-59 (3) CATEG 206-59 (3) CATEG 246-59 (3) CATEG 25-59 (3) CATEG 220-25 (4) CATEG 480-25 (4) CATEG 77-25 (4) CATEG 131-77 (5) CATEG 180-77 (5) CATEG 336-77 (5) CATEG 447-59 (3) CATEG 476-59 (3) CATEG 91-59 (3) CATEG 161-91 (4) CATEG 257-91 (4) CATEG 378-91 (4) CATEG 11-0 (0) CATEG 305-11 (1) CATEG 369-11 (1) CATEG 388-11 (1) CATEG 441-11 (1) CATEG 455-11 (1) CATEG 12-0 (0) CATEG 106-12 (1) CATEG 113-12 (1) CATEG 159-12 (1) CATEG 171-12 (1) CATEG 426-12 (1) CATEG 435-12 (1) CATEG 487-12 (1) CATEG 49-12 (1) CATEG 158-49 (2) CATEG 470-49 (2) CATEG 498-49 (2) CATEG 50-49 (2) CATEG 139-50 (3) CATEG 28-50 (3) CATEG 23-28 (4) CATEG 146-23 (5) CATEG 173-23 (5) CATEG 361-23 (5) CATEG 254-28 (4) CATEG 321-28 (4) CATEG 445-28 (4) CATEG 488-28 (4) CATEG 71-28 (4) CATEG 168-71 (5) CATEG 182-71 (5) CATEG 190-71 (5) CATEG 410-71 (5) CATEG 434-71 (5) CATEG 412-50 (3) CATEG 53-49 (2) CATEG 218-53 (3) CATEG 270-53 (3) CATEG 293-53 (3) CATEG 449-53 (3) CATEG 481-53 (3) CATEG 58-53 (3) CATEG 137-58 (4) CATEG 200-58 (4) CATEG 453-58 (4) CATEG 467-58 (4) CATEG 469-58 (4) CATEG 478-58 (4) CATEG 90-58 (4) CATEG 216-90 (5) CATEG 258-90 (5) CATEG 352-90 (5) CATEG 43-90 (5) CATEG 121-43 (6) CATEG 266-43 (6) CATEG 314-43 (6) CATEG 326-43 (6) CATEG 41-43 (6) CATEG 163-41 (7) CATEG 212-41 (7) CATEG 356-41 (7) CATEG 417-41 (7) CATEG 432-41 (7) CATEG 466-41 (7) CATEG 491-41 (7) CATEG 70-41 (7) CATEG 109-70 (8) CATEG 265-70 (8) CATEG 340-70 (8) CATEG 367-70 (8) CATEG 461-43 (6) CATEG 474-43 (6) CATEG 75-90 (5) CATEG 291-75 (6) CATEG 92-58 (4) CATEG 181-92 (5) CATEG 348-92 (5) CATEG 364-92 (5) CATEG 382-92 (5) CATEG 384-92 (5) CATEG 398-92 (5) CATEG 401-92 (5) CATEG 460-92 (5) CATEG 499-92 (5) CATEG 66-92 (5) CATEG 134-66 (6) CATEG 189-66 (6) CATEG 289-66 (6) CATEG 88-92 (5) CATEG 344-88 (6) CATEG 381-88 (6) CATEG 422-88 (6) CATEG 428-88 (6) CATEG 442-88 (6) CATEG 64-53 (3) CATEG 126-64 (4) CATEG 413-64 (4) CATEG 457-64 (4) CATEG 494-64 (4) CATEG 84-12 (1) CATEG 150-84 (2) CATEG 338-84 (2) CATEG 13-0 (0) CATEG 226-13 (1) CATEG 357-13 (1) CATEG 408-13 (1) CATEG 479-13 (1) CATEG 14-0 (0) CATEG 142-14 (1) CATEG 217-14 (1) CATEG 280-14 (1) CATEG 292-14 (1) CATEG 383-14 (1) CATEG 15-0 (0) CATEG 397-15 (1) CATEG 16-0 (0) CATEG 152-16 (1) CATEG 385-16 (1) CATEG 17-0 (0) CATEG 135-17 (1) CATEG 156-17 (1) CATEG 208-17 (1) CATEG 33-17 (1) CATEG 118-33 (2) CATEG 127-33 (2) CATEG 227-33 (2) CATEG 281-33 (2) CATEG 299-33 (2) CATEG 312-33 (2) CATEG 331-33 (2) CATEG 379-33 (2) CATEG 337-17 (1) CATEG 37-17 (1) CATEG 133-37 (2) CATEG 228-37 (2) CATEG 333-37 (2) CATEG 407-37 (2) CATEG 418-37 (2) CATEG 56-37 (2) CATEG 178-56 (3) CATEG 199-56 (3) CATEG 231-56 (3) CATEG 260-56 (3) CATEG 302-56 (3) CATEG 322-56 (3) CATEG 439-56 (3) CATEG 443-56 (3) CATEG 80-56 (3) CATEG 249-80 (4) CATEG 274-80 (4) CATEG 276-80 (4) CATEG 93-37 (2) CATEG 145-93 (3) CATEG 273-93 (3) CATEG 277-93 (3) CATEG 395-93 (3) CATEG 415-93 (3) CATEG 377-17 (1) CATEG 424-17 (1) CATEG 465-17 (1) CATEG 76-17 (1) CATEG 101-76 (2) CATEG 107-76 (2) CATEG 282-76 (2) CATEG 366-76 (2) CATEG 414-76 (2) CATEG 94-17 (1) CATEG 179-94 (2) CATEG 195-94 (2) CATEG 18-0 (0) CATEG 209-18 (1) CATEG 221-18 (1) CATEG 24-18 (1) CATEG 138-24 (2) CATEG 143-24 (2) CATEG 320-24 (2) CATEG 438-24 (2) CATEG 420-18 (1) CATEG 81-18 (1) CATEG 154-81 (2) CATEG 328-81 (2) CATEG 440-81 (2) CATEG 485-81 (2) CATEG 83-81 (2) CATEG 284-83 (3) CATEG 285-83 (3) CATEG 327-83 (3) CATEG 371-83 (3) CATEG 393-83 (3) CATEG 400-83 (3) CATEG 98-81 (2) CATEG 110-98 (3) CATEG 186-98 (3) CATEG 235-98 (3) CATEG 40-98 (3) CATEG 112-40 (4) CATEG 123-40 (4) CATEG 211-40 (4) CATEG 271-40 (4) CATEG 34-40 (4) CATEG 248-34 (5) CATEG 279-34 (5) CATEG 359-34 (5) CATEG 38-34 (5) CATEG 140-38 (6) CATEG 402-38 (6) CATEG 464-38 (6) CATEG 486-38 (6) CATEG 493-38 (6) CATEG 63-38 (6) CATEG 116-63 (7) CATEG 187-63 (7) CATEG 306-63 (7) CATEG 394-63 (7) CATEG 44-63 (7) CATEG 229-44 (8) CATEG 263-44 (8) CATEG 264-44 (8) CATEG 296-44 (8) CATEG 350-44 (8) CATEG 454-44 (8) CATEG 452-63 (7) CATEG 471-63 (7) CATEG 492-34 (5) CATEG 423-98 (3) CATEG 446-98 (3) CATEG 458-98 (3) CATEG 52-98 (3) CATEG 247-52 (4) CATEG 347-52 (4) CATEG 362-52 (4) CATEG 55-98 (3) CATEG 261-55 (4) CATEG 360-55 (4) CATEG 399-55 (4) CATEG 427-55 (4) CATEG 87-55 (4) CATEG 238-87 (5) CATEG 358-87 (5) CATEG 405-87 (5) CATEG 463-87 (5) CATEG 472-87 (5) CATEG 96-18 (1) CATEG 19-0 (0) CATEG 316-19 (1) CATEG 319-19 (1) CATEG 363-19 (1) CATEG 2-0 (0) CATEG 132-2 (1) CATEG 157-2 (1) CATEG 188-2 (1) CATEG 287-2 (1) CATEG 380-2 (1) CATEG 42-2 (1) CATEG 167-42 (2) CATEG 198-42 (2) CATEG 244-42 (2) CATEG 298-42 (2) CATEG 370-42 (2) CATEG 79-42 (2) CATEG 103-79 (3) CATEG 301-79 (3) CATEG 437-79 (3) CATEG 46-79 (3) CATEG 153-46 (4) CATEG 250-46 (4) CATEG 300-46 (4) CATEG 354-46 (4) CATEG 477-79 (3) CATEG 65-79 (3) CATEG 115-65 (4) CATEG 341-65 (4) CATEG 39-65 (4) CATEG 111-39 (5) CATEG 192-39 (5) CATEG 201-39 (5) CATEG 245-39 (5) CATEG 325-39 (5) CATEG 450-39 (5) CATEG 74-39 (5) CATEG 194-74 (6) CATEG 243-74 (6) CATEG 255-74 (6) CATEG 95-42 (2) CATEG 117-95 (3) CATEG 275-95 (3) CATEG 20-0 (0) CATEG 176-20 (1) CATEG 295-20 (1) CATEG 409-20 (1) CATEG 78-20 (1) CATEG 191-78 (2) CATEG 323-78 (2) CATEG 330-78 (2) CATEG 353-78 (2) CATEG 482-78 (2) CATEG 85-78 (2) CATEG 102-85 (3) CATEG 165-85 (3) CATEG 166-85 (3) CATEG 184-85 (3) CATEG 489-85 (3) CATEG 51-85 (3) CATEG 148-51 (4) CATEG 183-51 (4) CATEG 236-51 (4) CATEG 240-51 (4) CATEG 329-51 (4) CATEG 60-85 (3) CATEG 278-60 (4) CATEG 315-60 (4) CATEG 343-60 (4) CATEG 86-20 (1) CATEG 120-86 (2) CATEG 252-86 (2) CATEG 26-86 (2) CATEG 125-26 (3) CATEG 237-26 (3) CATEG 32-26 (3) CATEG 100-32 (4) CATEG 149-100 (5) CATEG 500-100 (5) CATEG 68-100 (5) CATEG 174-68 (6) CATEG 223-32 (4) CATEG 416-32 (4) CATEG 47-32 (4) CATEG 374-86 (2) CATEG 3-0 (0) CATEG 141-3 (1) CATEG 307-3 (1) CATEG 311-3 (1) CATEG 69-3 (1) CATEG 124-69 (2) CATEG 390-69 (2) CATEG 82-69 (2) CATEG 232-82 (3) CATEG 234-82 (3) CATEG 365-82 (3) CATEG 373-82 (3) CATEG 376-82 (3) CATEG 4-0 (0) CATEG 193-4 (1) CATEG 225-4 (1) CATEG 239-4 (1) CATEG 456-4 (1) CATEG 459-4 (1) CATEG 5-0 (0) CATEG 169-5 (1) CATEG 172-5 (1) CATEG 290-5 (1) CATEG 36-5 (1) CATEG 147-36 (2) CATEG 185-36 (2) CATEG 230-36 (2) CATEG 251-36 (2) CATEG 294-36 (2) CATEG 406-36 (2) CATEG 436-36 (2) CATEG 444-36 (2) CATEG 462-36 (2) CATEG 375-5 (1) CATEG 6-0 (0) CATEG 219-6 (1) CATEG 7-0 (0) CATEG 21-7 (1) CATEG 128-21 (2) CATEG 136-21 (2) CATEG 197-21 (2) CATEG 29-21 (2) CATEG 425-29 (3) CATEG 97-29 (3) CATEG 175-97 (4) CATEG 214-97 (4) CATEG 288-97 (4) CATEG 310-97 (4) CATEG 317-97 (4) CATEG 334-97 (4) CATEG 372-21 (2) CATEG 22-7 (1) CATEG 267-22 (2) CATEG 272-22 (2) CATEG 31-22 (2) CATEG 151-31 (3) CATEG 205-31 (3) CATEG 222-31 (3) CATEG 304-31 (3) CATEG 351-22 (2) CATEG 396-22 (2) CATEG 421-22 (2) CATEG 490-22 (2) CATEG 256-7 (1) CATEG 35-7 (1) CATEG 242-35 (2) CATEG 30-35 (2) CATEG 268-30 (3) CATEG 309-35 (2) CATEG 318-35 (2) CATEG 429-35 (2) CATEG 495-35 (2) CATEG 61-35 (2) CATEG 144-61 (3) CATEG 160-61 (3) CATEG 203-61 (3) CATEG 233-61 (3) CATEG 259-61 (3) CATEG 27-61 (3) CATEG 114-27 (4) CATEG 210-27 (4) CATEG 431-27 (4) CATEG 73-27 (4) CATEG 313-73 (5) CATEG 342-73 (5) CATEG 386-73 (5) CATEG 389-73 (5) CATEG 89-27 (4) CATEG 473-89 (5) CATEG 368-61 (3) CATEG 433-61 (3) CATEG 497-61 (3) CATEG 72-35 (2) CATEG 162-72 (3) CATEG 170-72 (3) CATEG 213-72 (3) CATEG 335-72 (3) CATEG 391-72 (3) CATEG 496-72 (3) CATEG 62-7 (1) CATEG 177-62 (2) CATEG 241-62 (2) CATEG 286-62 (2) CATEG 303-62 (2) CATEG 451-62 (2) CATEG 8-0 (0) CATEG 130-8 (1) CATEG 155-8 (1) CATEG 9-0 (0) CATEG 104-9 (1) CATEG 108-9 (1) CATEG 204-9 (1) CATEG 269-9 (1) CATEG 324-9 (1) CATEG 419-9 (1) |
|||
By: Skrol29
Date: 2005-01-17
Time: 03:20
|
Re: tree menu structuresI have the solution to display the tree with a simple block (row of table for example). But I'm still working on the <ul><li> problem which is more specific.
|
|||
By: iwan
Date: 2005-01-17
Time: 07:04
|
Re: tree menu structures |
|||
By: Skrol29
Date: 2005-01-17
Time: 18:52
|
Re: tree menu structuresHere is my solution. It is simple to use if you copy the 2 functions given above.
This solution works only for blocs with one section, using the simplified syntax. p1=[h.RootId] is a specific parameter that you must keep as is. [h.tbs_Level] is a fiels calculated by the function which return the level of the item (first level is #1). HTML part:
PHP part comming with the template:
PHP functions to add:
|
|||
By: iwan
Date: 2005-01-18
Time: 09:52
|
Re: tree menu structuresThanks Skrol29
but I need Mysql Table Structure to run this PHP Script..,Tks. |