So I am working on it first time. I created a Controller DB_DuhController
having a method actionFoo()
I am then calling it as http://domain.craft.dev/admin/DB/duh/Foo
but it's giving 404
all the time. What is wrong being done by me?
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communitySo I am working on it first time. I created a Controller DB_DuhController
having a method actionFoo()
I am then calling it as http://domain.craft.dev/admin/DB/duh/Foo
but it's giving 404
all the time. What is wrong being done by me?
You need to use /actions
(or whatever your Trigger word is) to access Controller actions.
Documentation: http://buildwithcraft.com/docs/config-settings#actionTrigger
EDIT: I realize I wasn't clear enough; this variable defaults to /actions
. Unless you've set it to something else in your Config, add the /actions
to your URL to access the Controller action.
So, your URL would be this: http://domain.craft.dev/actions/PluginHandle/Duh/foo
Note that capitalization matters.
It's also important to make sure that if you plan on making calls to this URL from outside Craft, you'll need to make sure that you're allowing anonymous access by setting that variable at the top of your controller:
protected $allowAnonymous = true;
/actions/db/dauh/foo
– Luke Holder
Oct 21 '15 at 6:57
/admin/db/duh/foo
with lower case db? I think the plugin name is lowercase for first letter: buildwithcraft.com/docs/plugins/… same with action namefoo
notFoo
. Also assume you have a CP route in place for the/admin
request. – Luke Holder Oct 20 '15 at 9:39/admin
is working but not after that. – Volatil3 Oct 20 '15 at 10:25hookRegisterCpRoutes
method is empty. Do I need to define routes first? – Volatil3 Oct 20 '15 at 10:27