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

  • cadch

  • Just popping in

  • Posts: 55

  • Since: 2007/12/17


Hello~
My tree used
le="color: #000000"><?php 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: 11521

  • 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:

le="color: #000000"><?php require_once XOOPS_ROOT_PATH . '/class/xoopstree.php'; $tree = new XoopsTree();


2. Define the XOOPS tree structure using the array:

le="color: #000000"><?php $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:

le="color: #000000"><?php $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: 55

  • Since: 2007/12/17


Thank Mamba~

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

  • cadch

  • Just popping in

  • Posts: 55

  • Since: 2007/12/17


I have a message
le="color: #000000"><?php 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: 11521

  • Since: 2004/4/23


My mistake! My apologies!

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

Please use this line:
le="color: #000000"><?php 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: 55

  • Since: 2007/12/17


Thank Mamba~
I connect database change
le="color: #000000"><?php $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: 11521

  • Since: 2004/4/23


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

le="color: #000000"><?php $tree->getChildTreeArray(0, 'title ASC');
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

Who's Online

86 user(s) are online (47 user(s) are browsing Support Forums)


Members: 0


Guests: 86


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits