How to access a controller action , from ctp file in CakePHP 3
up vote
1
down vote
favorite
I want to access a controller action from ctp file. Here my action name and ctp file name is different. For example I created an action in the name of tickets ,and my view ctp file name is ticket_title. How to do this ?
This is my action : ticket
class UsersController extends AppController
{
public function ticket()
{
$ticket=$this->Tickets->find('all');
$this->set(compact('ticket'));
}
}
My view ctp file : ticket_title.ctp
<?php
$this->requestAction(array('controller' => 'users', 'action' => 'ticket'));
foreach($ticket as $ticket1)
{
echo $ticket1->title."<br/>";
}
Can any one help me ?.
model-view-controller action cakephp-3.x ctp
add a comment |
up vote
1
down vote
favorite
I want to access a controller action from ctp file. Here my action name and ctp file name is different. For example I created an action in the name of tickets ,and my view ctp file name is ticket_title. How to do this ?
This is my action : ticket
class UsersController extends AppController
{
public function ticket()
{
$ticket=$this->Tickets->find('all');
$this->set(compact('ticket'));
}
}
My view ctp file : ticket_title.ctp
<?php
$this->requestAction(array('controller' => 'users', 'action' => 'ticket'));
foreach($ticket as $ticket1)
{
echo $ticket1->title."<br/>";
}
Can any one help me ?.
model-view-controller action cakephp-3.x ctp
Possible duplicate: stackoverflow.com/questions/30318793/…
– Inigo Flores
Jan 19 '16 at 18:46
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to access a controller action from ctp file. Here my action name and ctp file name is different. For example I created an action in the name of tickets ,and my view ctp file name is ticket_title. How to do this ?
This is my action : ticket
class UsersController extends AppController
{
public function ticket()
{
$ticket=$this->Tickets->find('all');
$this->set(compact('ticket'));
}
}
My view ctp file : ticket_title.ctp
<?php
$this->requestAction(array('controller' => 'users', 'action' => 'ticket'));
foreach($ticket as $ticket1)
{
echo $ticket1->title."<br/>";
}
Can any one help me ?.
model-view-controller action cakephp-3.x ctp
I want to access a controller action from ctp file. Here my action name and ctp file name is different. For example I created an action in the name of tickets ,and my view ctp file name is ticket_title. How to do this ?
This is my action : ticket
class UsersController extends AppController
{
public function ticket()
{
$ticket=$this->Tickets->find('all');
$this->set(compact('ticket'));
}
}
My view ctp file : ticket_title.ctp
<?php
$this->requestAction(array('controller' => 'users', 'action' => 'ticket'));
foreach($ticket as $ticket1)
{
echo $ticket1->title."<br/>";
}
Can any one help me ?.
model-view-controller action cakephp-3.x ctp
model-view-controller action cakephp-3.x ctp
edited Jan 19 '16 at 17:53
asked Jan 19 '16 at 17:35
Balasuresh Asaithambi
347314
347314
Possible duplicate: stackoverflow.com/questions/30318793/…
– Inigo Flores
Jan 19 '16 at 18:46
add a comment |
Possible duplicate: stackoverflow.com/questions/30318793/…
– Inigo Flores
Jan 19 '16 at 18:46
Possible duplicate: stackoverflow.com/questions/30318793/…
– Inigo Flores
Jan 19 '16 at 18:46
Possible duplicate: stackoverflow.com/questions/30318793/…
– Inigo Flores
Jan 19 '16 at 18:46
add a comment |
3 Answers
3
active
oldest
votes
up vote
2
down vote
Finally , it works by using render() method.
In my action:
public function ticket()
{
$this->loadModel('Tickets');
$ticket=$this->Tickets->find('all');
$this->set(compact('ticket'));
$this->render('ticket_title');
}
And this is my ticket_title.ctp
<?php
foreach($ticket as $ticket1)
{
echo $ticket1->title."<br/>";
}
add a comment |
up vote
0
down vote
Yes, its working in CTP of Cake PHP 3 . You can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
add a comment |
up vote
0
down vote
you can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
Finally , it works by using render() method.
In my action:
public function ticket()
{
$this->loadModel('Tickets');
$ticket=$this->Tickets->find('all');
$this->set(compact('ticket'));
$this->render('ticket_title');
}
And this is my ticket_title.ctp
<?php
foreach($ticket as $ticket1)
{
echo $ticket1->title."<br/>";
}
add a comment |
up vote
2
down vote
Finally , it works by using render() method.
In my action:
public function ticket()
{
$this->loadModel('Tickets');
$ticket=$this->Tickets->find('all');
$this->set(compact('ticket'));
$this->render('ticket_title');
}
And this is my ticket_title.ctp
<?php
foreach($ticket as $ticket1)
{
echo $ticket1->title."<br/>";
}
add a comment |
up vote
2
down vote
up vote
2
down vote
Finally , it works by using render() method.
In my action:
public function ticket()
{
$this->loadModel('Tickets');
$ticket=$this->Tickets->find('all');
$this->set(compact('ticket'));
$this->render('ticket_title');
}
And this is my ticket_title.ctp
<?php
foreach($ticket as $ticket1)
{
echo $ticket1->title."<br/>";
}
Finally , it works by using render() method.
In my action:
public function ticket()
{
$this->loadModel('Tickets');
$ticket=$this->Tickets->find('all');
$this->set(compact('ticket'));
$this->render('ticket_title');
}
And this is my ticket_title.ctp
<?php
foreach($ticket as $ticket1)
{
echo $ticket1->title."<br/>";
}
answered Jan 20 '16 at 8:25
Balasuresh Asaithambi
347314
347314
add a comment |
add a comment |
up vote
0
down vote
Yes, its working in CTP of Cake PHP 3 . You can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
add a comment |
up vote
0
down vote
Yes, its working in CTP of Cake PHP 3 . You can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
add a comment |
up vote
0
down vote
up vote
0
down vote
Yes, its working in CTP of Cake PHP 3 . You can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
Yes, its working in CTP of Cake PHP 3 . You can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
edited Nov 17 at 17:05
Agilanbu
867617
867617
answered Nov 17 at 7:01
Gaurav Singhal
1
1
add a comment |
add a comment |
up vote
0
down vote
you can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
add a comment |
up vote
0
down vote
you can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
add a comment |
up vote
0
down vote
up vote
0
down vote
you can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
you can use this object in any other controller or in ctp file where needed
(in case of controller)
use AppControllerControllerName;
$ControllerNameObj = new ControllerName;
$ControllerNameObj->functionName();
(in case of ctp file)
$abcObj = new AppControllerHomeController;
$fetchdetail = $abcObj->ControllerfunctionName($parameter1, $parameter2);
edited Nov 19 at 7:18
Agilanbu
867617
867617
answered Jun 4 at 10:38
Mohit saini
11
11
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f34883390%2fhow-to-access-a-controller-action-from-ctp-file-in-cakephp-3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate: stackoverflow.com/questions/30318793/…
– Inigo Flores
Jan 19 '16 at 18:46