Welcome Guest, Not a member yet? Register   Sign In
MPTtree, Hieararchical trees in a database table
#61

[eluser]Base Willy[/eluser]
pistolPete, thanks for your questions.

I'm using extjs provided with admin example.CSS and JS files are loaded correctly. I see it works and tries to load the tree but in firebug i see that tree_admin/get_node returns an empty result.. and still there are no errors in log
#62

[eluser]Base Willy[/eluser]
Oopy.. I found the reason. It's because in node_text it's using the 'slug' index but i have 'title' Smile
#63

[eluser]Base Willy[/eluser]
..but now i got another problem. When i try to add a new child node it does something with mysql and after that i only see is:
Code:
Error Number: 1100
Table 'sessions' was not locked with LOCK TABLES

and only after restarting mysql server i can see admin_tree main page again..
#64

[eluser]pistolPete[/eluser]
You probably misconfigured it somehow... please post some code!
How are you using the "sessions" table combined with MPTtree?
Are you using the current Version of MPTtree (0.1.6-fix2) ?

Btw, I would recommend also using the latest Ext JS (which is v 2.2 at the moment).

If you want to, I can post an updated example...
#65

[eluser]Code Arachn!d[/eluser]
similar to the suggested update_node_by_id function I've just added a method on my own version to reinsert a node:

Code:
function reinsert_node($lft,$arg,$lock = true){
        $root = $this->get_root();
        if($lft > $root[$this->right_col] || $lft < 1)return false;
        if ($lock)
            $this->lock_tree_table();

        $this->db->query('UPDATE '.$this->tree_table.
                        ' SET '.$this->left_col.' = '.$this->left_col.' + 2 '.
                        ' WHERE '.$this->left_col.' >= '.$lft);
        $this->db->query('UPDATE '.$this->tree_table.
                        ' SET '.$this->right_col.' = '.$this->right_col.' + 2 '.
                        ' WHERE '.$this->right_col.' >= '.$lft);
    
        $this->db->where($arg);
        $this->db->update($this->tree_table,array($this->left_col => $lft,$this->right_col => $lft+1));
        if ($lock)
            $this->unlock_tree_table();
        return true;
    }

The idea is to take a record already in the table and add it back into the tree.
#66

[eluser]m4rw3r[/eluser]
Maybe there is a wrong uri?
It was really some time since I've looked at that source (and I was rewriting MPTTree when I suddenly got other things to do),
so I'm sorry if I'm not so good at helping you for the moment.
#67

[eluser]Base Willy[/eluser]
In tree_admin, after right clicking on the root node (which i've added manually) and then clicking New page->New child page what should i see? I don't see anything and there is an error in firebug:
Code:
missing } in XML expression
[Break on this error] background-color: #fff;\n
ext-all.js (line 29)
But if i click on ext-all-js i see normal ext-all.js source..
#68

[eluser]m4rw3r[/eluser]
For all those who are asking for the 1.6-fix2 version (the latest, which was posted on CI base), here it is.
#69

[eluser]antonumia[/eluser]
this is a really useful addition and I plan to post my controller implementation of it when I've finished.

i have a problem when trying to move a node i.e. the node does not move using the following. I have the lft ids of each node in a tree passed in as $nodeid

Code:
function moveNodeUp($nodeid){
    $node = intval($nodeid);
    if ($node == 1){
        echo 'node is root';
exit();
    }
        
    $tnode = $this->backend->getNodeLeft($node - 1); // returns the lft value using rgt
    if ($tnode){
        $src = $this->getNodeById($node);
        $tgt = $this->getNodeById($tnode);
        $res =  $src->move_above($tgt);
        echo 'moved:' . $res;
    } else {
        echo 'target doesn\'t exist';
    }
        
    $this->index();
        }

thanks

anton
#70

[eluser]Antivanity[/eluser]
I'm having problems with this..


Code:
$this->load->MPTT('user_tree');
$this->user_tree->insert_root(array('title'=>'FAS', 'userid'=>'1'));

Quote:PHP Fatal error: Cannot pass parameter 1 by reference in /home/camalotlms.com/system/application/models/mpttree.php on line 405

Heres the function that the error is in..

Code:
function get_root(){
        $query = $this->db->getwhere($this->tree_table,array($this->left_col => 1),1);
        $return = $query->num_rows() ? $query->row_array() : false;
        if(!$return)
            $this->debug_message('Root node was not found.'); // this is like 405 with the error..
        return $return;
    }




Theme © iAndrew 2016 - Forum software by © MyBB