1
cadch
How to use XOOPS tree?
  • 2023/7/17 14:41

  • cadch

  • Just popping in

  • Posts: 51

  • Since: 2007/12/17


Hello~
My tree used
array(
array(
'id' => 1'parent' => 0),
array(
'id' => 2'parent' => 0),
array(
'id' => 3'parent' => 0),
array(
'id' => 4'parent' => 1),
array(
'id' => 5'parent' => 4),
array(
'id' => 6'parent' => 5)
);

How can I use XOOPS tree?

2
Mamba
Re: How to use XOOPS tree?
  • 2023/7/20 0:42

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


To utilize the XOOPS tree structure for the given array, you can follow these steps:

1. Initialize the XOOPS Tree class:

require_once XOOPS_ROOT_PATH '/class/xoopstree.php';
$tree = new XoopsTree();


2. Define the XOOPS tree structure using the array:

$treeData = array(
    array(
'id' => 1'parent' => 0),
    array(
'id' => 2'parent' => 0),
    array(
'id' => 3'parent' => 0),
    array(
'id' => 4'parent' => 1),
    array(
'id' => 5'parent' => 4),
    array(
'id' => 6'parent' => 5)
);

foreach (
$treeData as $data) {
    
$tree->addNode($data['id'], $data['parent']);
}



3. Retrieve the tree structure using the XOOPS Tree class:

$treeStructure $tree->getChildTreeArray(0);


The `$treeStructure` variable will contain the hierarchical structure of the tree, starting from the root node with ID 0. You can then process and utilize this structure as per your requirements.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

3
cadch
Re: How to use XOOPS tree?
  • 2023/7/21 11:38

  • cadch

  • Just popping in

  • Posts: 51

  • Since: 2007/12/17


Thank Mamba~

4
cadch
Re: How to use XOOPS tree?
  • 2023/7/21 14:33

  • cadch

  • Just popping in

  • Posts: 51

  • Since: 2007/12/17


I have a message
Error: Class "XoopsTree" not found

Can you help me

5
Mamba
Re: How to use XOOPS tree?
  • 2023/7/23 8:27

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


My mistake! My apologies!

It should be /xoopstree.php and not /tree.php

Please use this line:
require_once XOOPS_ROOT_PATH '/class/xoopstree.php';
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

6
cadch
Re: How to use XOOPS tree?
  • 2023/8/5 16:52

  • cadch

  • Just popping in

  • Posts: 51

  • Since: 2007/12/17


Thank Mamba~
I connect database change
$tree = new XoopsTree($table,'id','parent');

Is succeeded.
I have a request
"class XoopsTree function"
Is it possible to add options for "ASC" and "DESC"?

7
Mamba
Re: How to use XOOPS tree?
  • 2023/8/12 8:04

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Yes, when you use the getChildTreeArray function, you include it like this:

$tree->getChildTreeArray(0'title ASC');
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

Login

Who's Online

390 user(s) are online (264 user(s) are browsing Support Forums)


Members: 0


Guests: 390


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits