GithubHelp home page GithubHelp logo

ci-nested-sets's People

Contributors

jaoustin avatar olimortimer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ci-nested-sets's Issues

how can i move two main nodes that have no targets ?

In the attached file how can i move Plastics and Electronics :

untitled

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) ?

Path generation

It would be nice to add a path field and implement the generation of the full path to the root element.

table mysql?

Where I can find the mysql table or documentation relating to this library?

looping forever in getSubTreeAsHTML

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;
    }

Samples

hi can you provide some example of use?

ordered tree

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 want create Root Tree

i have db

id
parent_id
lft
rgt
title
slug
type

with type is category, post...

how to create Tree with category or post

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.