Questions tagged [controller]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
1answer
2k views

Controller action works but still gives 404

I'm writing my first plugin and I'm slowly getting there, but I hit on a problem: I have a controller class in which I have a function that sets a cookie. I call on this function from within a ...
5
votes
1answer
2k views

Rendering templates from plugin controller

Right now I'm trying to accomplish routing users through a controller action before rendering the plugin's CP template... [Plugin]Plugin.php // ... public function registerCpRoutes() { return [...
4
votes
1answer
987 views

Is the “registerSiteRoutes” hook screwing up my template path?

This may be a bug... I have a controller action which has been working great. It's a simple action with a single purpose... load a template with an internal value. public function actionMyAction() { ...
7
votes
2answers
744 views

Best way to use custom enums in my plugin templates?

I am building a plugin that's uses an enum for custom statuses. The statuses are integrated within my plugin with the exception of changing the status in my template code. pluginname/enums/...
6
votes
1answer
620 views

Allow anonymous submission on a custom element type?

I have a custom element type that I want to allow anonymous submission from the front-end. I have a solid concept on how the form data is passed but I seem to be missing something. I have the ...
5
votes
1answer
214 views

Plugin routing casing: camel, lower, Pascal

Recently got tripped up with plugin routing due to casing. It seems when you're in the control panel, your "plugin handle" is lower-cased in routes, though both seem to work: /cp/settings/plugins/...
4
votes
1answer
984 views

Creating sessions in Twig

I am trying to create the PHP $_SESSION equivalent in Craft CMS using Twig. I have searched very long and I can't find how you can create sessions in Twig. In previous posts I have found that I ...
3
votes
1answer
502 views

How to tell if user exists

I am automatically creating users in a service, is there a way to check if user exists? I want to log in id user exist or save a new user if it doesn't, I have the following so far which will add a ...
4
votes
1answer
790 views

How can I ensure using actionUrl in my template does not show script name in the generated URL?

I have an controller action in my custom plugin that processes Paypal IPN requests. How it works is that you provide a URL for Paypal to send it's notification requests to and then process them and ...
2
votes
1answer
46 views

Update a lightswitch field in Craft CMS 2

How can I edit a lightswitch field in an entries field layout via PHP? This is my current approach public function actionSponsoredEntriesPriority() { $this->requireAdmin(); $this->...
1
vote
1answer
396 views

Call Craft controller with cron job

I am making a plugin which has a controller to be called every hour. My server environment is using Anacron. So I wrote this anacron job: 1@hourly 0 cron.hourly wget http://www.mydomain.com/actions/...