Hi there.
I am new in cakePHP. I make a controller AbcContoller
and for controller I create its view AbcController
. Now in AbcController
there are several tasks e.g.
- Events add
- Products add
And that’s why I create sub folders e.g.
- Events
- Products
I make events method in AbcController
and get data form DB and when I set this data to subfolder view, it gives me this error
[Notice (8)] Undefined variable: AbcEvents [ APP\View\Abc\Events\evetns.ctp
I also add router in my routes.php
Router::connect('/Abc/Events/Listing/', array('controller' => 'Abc', 'action' => 'events'));
My controller Code:
`public function events() {
$this->login_check();
// Render from sub folder
$this->render('Events/events');
$abc_events = $this->AbcEvents->find('first',
array('order' => array('AbcEvents.id DESC')));
// echo “
”;”;
// print_r($abc_events);
// echo “
$this->set('AbcEvents', $abc_events);
}`
When I print data in controller it gives me correct data but not in view.
My view Code Views/Abc/events/events.ctp:
<?php echo "<pre>"; print_r($AbcEvents); echo "</pre>";
It gives me undefined variable error.
How can I get data in view of a sub folder.
Hope you understand my question.