joern
(jrn)
January 10, 2012, 9:34pm
1
I just read about the advanced action technique in the documentation.
So I created a test file call TestAction.php under /protected/controllers/test/TestAction.php
And in the controller ‘TestController.php’ under /protected/controllers/ I inserted
<?php
class TestController extends Controller
{
public function actions()
{
return array(
'page'=>array(
'class'=>'CViewAction',
),
'test'=>'application.controllers.test.TestAction',
);
}
}
The TestAction.php file looks like:
<?php
class TestAction extends CAction
{
public function run()
{
echo "Test";
}
}
If I call this action using index.php?r=test/test in the browser, I get the following error message:
Any thoughts on what I could be missing here?
bettor
(Live Webscore)
January 10, 2012, 10:17pm
2
check that you have protected/controllers/test/TestAction.php
mdomba
(Maurizio Domba Cerin)
January 10, 2012, 10:28pm
3
If the file is there… check for proper case of the file ie. TestAction.php… and the file and parent folder permissions
joern
(jrn)
January 11, 2012, 2:08pm
4
Thanks mdomba. It was indeed a problem with the folder’s permissions. Now it is working just fine
joern
(jrn)
January 11, 2012, 3:00pm
5
Now, how could I combine these two things:
With the help of this topic I created a method in my controller.
With mdomba’s help I managed to put the actions, which I used to have in my controller, into a file in a new folder.
Since the method still remains inside the controller what would be the appropriate way to call this method from inside the actions which is in the new folder? I believe $this is not an option anymore.
tri
(tri - Tommy Riboe)
January 11, 2012, 3:14pm
6
I would try $this->controller.
/Tommy
joern
(jrn)
January 11, 2012, 3:32pm
7
Hi Tommy,
I tried $this->TestController->getSiteModel(); but had no luck.
However, if I use TestController::getSiteModel(); it works.
Unfortunately I get the following error message now:
Any thoughts on how I could solve this problem?
tri
(tri - Tommy Riboe)
January 11, 2012, 3:41pm
8
You should try $this->controller->getSiteModel().
/Tommy