Well, problem solved...don't know if I did it the right way, though...

Since the variable I was trying to use in my component was an array of data
from a table, I had to import the model in the component using: 

        $Category = ClassRegistry::init('Category');        

So I set the array after that, in the component as well, like this:

   $categories = $Category->find('all',array(
                'conditions'=>array('Category.active'=>1),
                'order'=> array('Category.index'=>'ASC')
        ));

Thanks!


mig_akira wrote:
> 
> Hello everyone.
> 
> I'm trying to build a simple dropdown menu for a website. I'm using this
> tutorial:
> http://www.palivoda.eu/2008/04/dynamic-menu-in-cakephp/
> 
> THe menu is working, but I don't know how can I pass the array with all
> the data to build the menu from the app_controller to the menu component. 
> 
> I was using a simple element menu, with this in my appcontroller's
> beforeFilter:
> 
> function _setLayoutFrontEnd()
>     {
>       $this->layout = 'default';
>         $this->_loadMenu();
>     }
> 
>     function _loadMenu()
>     {
>               $categories = $this->Category->find('all',array(
>               'conditions'=>array('Category.ativo'=>1),
>               'order'=> array('Category.indexpag'=>'ASC')
>       ));
>       $this->set('categories',$categories);
> }
> 
> With that, I could use the array $categories in my view/elements/menu.ctp. 
> 
> Now I need to pass it to my controllers/components/menu.php. 
> How can I do that?
> 
> Thanks!!!
> 

-- 
View this message in context: 
http://www.nabble.com/how-can-I-pass-variable-from-app_controller-to-a-component--tp25530525p25530987.html
Sent from the CakePHP mailing list archive at Nabble.com.


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

Reply via email to