Welcome Guest, Not a member yet? Register   Sign In
Getting started with IgnitedRecord and MPTTree
#1

[eluser]Andreas Krohn[/eluser]
I am using IgnitedRecord and it works like a charm. Now I want to use the IgnitedRecord behaviour Tree to use MPTtree, but that is where I run into problems. I suspect that I have not loaded the libraries etc I need correctly, but nothing I try seems to work....

The db is setup according to the manual, ie with id, lft, rgt and title. The MPTtree model is in my application/model directory.

This is my model:
Code:
class locations extends IgnitedRecord {    
   var $act_as = 'tree';          

   function locations() {        
      parent::IgnitedRecord();    
   }    
}

In the constructor of my controller I load ORM and the locations model:
Code:
$this->load->ORM();
$this->load->model('locations');

In my controller I now want to find a location from my table and then check what parent the location has, this is what I try:
Code:
$country = $this->locations->find_by("title", "Sweden");
$parent = $country->parent();
However, I keep getting error messages like "IgnitedRecord: IR_record: Method parent() is not found." Have also tried calls like $country->tree->parent() etc, but no luck. I would be very grateful if anybody tell me what I am doing wrong, this is driving my crazy.
#2

[eluser]Andreas Krohn[/eluser]
Some hours later and I have had some success. Needed to set the tree_table in the model, but that was not enough. In the behaviour file tree.php I needed to change the name of the constructor from IgnitedRecord_tree to IR_tree as well as adding this line last in the IgnitedRecord_tree_helper function:
Code:
$this->instance = $this->mpttree;

Now things seem to work, at least I can now add new nodes to the tree.

Do I really need to do these things to make things work or am I just complicating things? Does anybody else have the same problems?




Theme © iAndrew 2016 - Forum software by © MyBB