olimortimer / ci-nested-sets Goto Github PK
View Code? Open in Web Editor NEWNested Set Library for CodeIgniter
Nested Set Library for CodeIgniter
In the attached file how can i move Plastics and Electronics :
for moving any other sub nodes i do this :
$cat = $this->nested_set->getNodeFromId($cat_id);
if($cat["cat_parent_id"]){
$parent = $this->nested_set->getNodeFromId($cat["cat_parent_id"]);
if($direction == "up"){
$this->nested_set->setNodeAsFirstChild($cat , $parent);
}else{
$this->nested_set->setNodeAsLastChild($cat , $parent);
}
}
I there any way to :
1- move nodes by one step ( not as first child or last child ) ?
2- move main nodes that have no targets (parents) ?
It would be nice to add a path field and implement the generation of the full path to the root element.
Where I can find the mysql table or documentation relating to this library?
why do not you make any examples or documentation ?
The while loop is looping forever
public function getSubTreeAsHTML($nodes, $fields = array()) {
if(isset($nodes[0]) && !is_array($nodes[0])) {
$nodes = array($nodes);
}
$retVal = '';
foreach($nodes AS $node) {
$tree_handle = $this->getTreePreorder($node);
while($this->getTreeNext($tree_handle))
{
// print indentation
$retVal .= (str_repeat(' ', $this->getTreeLevel($tree_handle)*4));
// print requested fields
$field = reset($fields);
while($field){
$retVal .= $tree_handle['row'][$field] . "\n";
$field = next($fields);
}
$retVal .= "<br />\n";
}
}
return $retVal;
}
how can i move node to become a tree
hi can you provide some example of use?
You can share a document to use it ?
why not use something like this to get the ordered tree ?
SELECT node.name, (COUNT(parent.name) - 1) AS depth
FROM product_category AS node
CROSS JOIN product_category AS parent
WHERE node.lft BETWEEN parent.lft AND parent.rgt
GROUP BY node.name
ORDER BY node.lft
and render
function renderTree($tree, $currDepth = -1) {
$currNode = array_shift($tree);
$result = '';
// Going down?
if ($currNode['depth'] > $currDepth) {
// Yes, prepend <ul>
$result .= '<ul>';
}
// Going up?
if ($currNode['depth'] < $currDepth) {
// Yes, close n open <ul>
$result .= str_repeat('</ul>', $currDepth - $currNode['depth']);
}
// Always add the node
$result .= '<li>' . $currNode['name'] . '</li>';
// Anything left?
if (!empty($tree)) {
// Yes, recurse
$result .= renderTree($tree, $currNode['depth']);
}
else {
// No, close remaining <ul>
$result .= str_repeat('</ul>', $currNode['depth'] + 1);
}
return $result;
}
i have db
id
parent_id
lft
rgt
title
slug
type
with type is category, post...
how to create Tree with category or post
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.