0

I'm trying to create a dynamic menu by adding variables in every controller. Each controller will hold its own links which will be generated in the default template ( default.ctp ). The thing where I am stuck right now is that I have no clue how to get all the controllers as an object so I can retrieve the data right away. I do know how to get all the names.

To get the names I used;

App::objects('Controller');

Beside that, I'm using cakephp 2.5.1 :)

tereško
  • 58,060
  • 25
  • 98
  • 150
Tosfera
  • 512
  • 3
  • 14
  • what do you mean "as an object" ? – AD7six Jun 20 '14 at 09:46
  • Ah, that might be confused alot. I'm trying to use it as an object again. Like, I want to be able to loop trough all the controllers and call the elements in it. Something like; $cController->menu – Tosfera Jun 20 '14 at 09:47
  • 2
    so "as an object" means creating an instance of each controller? In your layout? For all requests? That's imo a pretty bad idea. Alternatively controllers are just a class - you're asking "how can I create an instance of a class" - which should be pretty obvious. – AD7six Jun 20 '14 at 09:52
  • Any idea how I could build up a menu ( ul, li, a ) which takes each controller and their own links ( thinking about adding an array in a controller which holds the items )? Oh and I need to use it in the view again. ^^" – Tosfera Jun 20 '14 at 09:54

0 Answers0