Does the model implement TreeBehavior? I think this should work:

$var_model = $this->Controller->modelClass;

if (!empty($data[$var_model]['parent_id']))
{
        $id = $data[$var_model]['id'];
        $parent_id = $data[$var_model]['parent_id'];

        $path =  $this->Controller->{$var_model}->getpath($parent_id);
        // or ...
        //$path =  $this->Controller->{$var_model}->getpath($id);
}

I don't know what all of those other $var_* are for.

On Wed, May 6, 2009 at 6:57 AM, ixopo <i...@townhill-park.com> wrote:
>
> Hello everybody,
>
> i am really desperate.
>
> I wrote a SEO Component which automatically tries to read SEO Relevant
> Tags from the Database like Title, Keywords, Description and even the
> URL. Works great so far.
> But for Categories i want to have the whole CategoriePath for the
> Title (for Example MetaTitle: Cakes - Fancy Cakes - Creamy Cakes). I
> try to get this done with the TreeBehaviour -> getpath.  But at the
> time i am importing the TreeBehaviour (see code below) in my SEO
> Component i get ErrorMessage like this:
>
> Notice (8): Trying to get property of non-object [ROOT/
> cake_1.2.3.8166/
> cake/libs/model/behaviors/tree.php, line 406]
> Notice (8): Undefined index:   [ROOT/cake_1.2.3.8166/cake/libs/model/
> behaviors/tree.php, line 406]
>
> Warning (2): extract() [function.extract]: First argument should be an
> array [ROOT/cake_1.2.3.8166/cake/libs/model/behaviors/tree.php, line
> 406]
>
> Fatal error: Call to a member function find() on a non-object in /mnt/
> data/home/ixopo/public_html/emmall/cake_1.2.3.8166/cake/libs/model/
> behaviors/tree.php on line 410
>
> Somehow itz loading the TreeBehaviour but "find()" in "tree.php"
> doesnt work. How come ?
> Whatz wrong in my code ?
>
> Extract from the SEO Component, relevant part:
>
> if(!empty($data[$this->Controller->modelClass]['parent_id'])){
>                $id = $data[$this->Controller->modelClass]['id'];
>                $parent_id = $data[$this->Controller->modelClass]
> ['parent_id'];
>
>                App::import('Behaviour', 'Tree');
>                $tree =new TreeBehavior;
>
>                $var_model = $this->Controller->modelClass;
>                $var_id = '18';
>                $var_name = array('meta_title', 'title', 'name');
>                $var_recursive ='';
>
>                $parents =  $tree->getpath($var_model, $var_id,
> $var_name,
> $var_recursive);
>
>        }
>
> Thx 4 any help and suggestions!!!
>
> Greetz
> ixopo
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to