Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [controller]

The tag has no usage guidance.

0
votes
0answers
4 views

Some (but not all) controller action routes return 404 on staging server

I've created a module for a project that has several actions, all of which are called through AJAX. Each is a post request that sends over any required params plus the CSRF token using the method ...
1
vote
2answers
24 views

Action URLs from CP to a Craft 3 plugin controller

I'm working on my first Craft 3 plugin and want to add some buttons to my plugin's control panel section which post form data to a controller. My plugin is called 'myplugin', the controller I wish to ...
1
vote
1answer
18 views

How can I pass a variable defined in a Controller to my variables?

In my Craft 3 plugin I would like to pass a variable defined in my Controller to my PluginVariable.php file. Is this possible?
1
vote
2answers
31 views

How to disable plugin Disable and Uninstall?

I am developing a site with a customer logged in area. I don't want anyone to access the section if they are logged out and instead redirect them to the login form. I could just add {% requireLogin %...
1
vote
1answer
40 views

How can I call console controllers

I have a controller in the console folder. How can I call this controller via ajax please? I tried to config a route in Routes.php, and then call this route by jquery Get() function. But none of ...
1
vote
1answer
137 views

“Template Not Found” error when trying to access a module controller action

I'm a total Craft newbie, so I hope this question isn't ridiculous. I just want to see a controller / action work in my new module. I have src/controllers/ScrapeController.php as such: <?php ...
0
votes
0answers
89 views

Unable to call a service method from controller in my custom plugin

I know there are similar questions here, but I don't see a definitive answer, nor one that works for me. I've generated a plugin via pluginfactory.io, which has some controllers and a single service. ...
2
votes
1answer
175 views

Craft 3 Controller giving 404

Updating a plugin to Craft 3 (also changed its name). I know this is probably something very simple, like capitalization, but can anyone point out what's wrong? Firefox console shows a 404 for http://...
2
votes
1answer
33 views

Add a button to the entry edit screen via plugin

I would like to add a button to the edit entry screen, only for already saved entries, alongside the "Share" button. When clicked, I'd like to call my plugin's controller action and post the entry ID....
1
vote
1answer
401 views

How to call Controller in Module?

I'm very new to craft and I'm having trouble finding an answer to my question (I've scoured the questions on here - but the only answers appear to be for plugins). Basically, I want to submit a form ...
0
votes
0answers
200 views

Plugin Development (Craft 3): Pass variables with redirection

I'm building out a Craft 3 plugin and can't see who to pass variables with redirection from a controller. For example, I have a controller that I want to pass back to the defined redirect value ...
1
vote
1answer
63 views

How to render template instead of throwing an error?

I'm working on a plugin that hooks into Craft's Guest Entries plugin. I want to send a confirmation mail after an entry has been saved. This works nicely so far. Now I want to catch any errors in ...
1
vote
1answer
152 views

Filter entries by ajax to controller

Short story: I need your help sending value from dropdown selection as data to controller so my div updates with the filtered entries based on the selection. Long story and code: I have a listing of ...
0
votes
0answers
202 views

craft.request.getPost() returns empty array

Using Postman to perform a POST request to a page I have set up with the following. content-type is application/json Post Body {"id":123} Template {{ dump(craft.request.getPost()) }} Response ...
3
votes
0answers
320 views

Craft 3 Plugin - Only default action works

I'm working on a Cloudflare integration plugin for Craft 3. I set up the plugin with settings, which works fine so far. Now I intended to verify the Cloudflare credentials using an AJAX call. I set ...
1
vote
1answer
63 views

Save Entry Data as CSV and Email it to the Author / Logged in User

I am trying to email some Entry data that they have created in CSV Format to the author/logged in user. I have a controller setup with a frontend form posting an action to the controller: public ...
1
vote
1answer
42 views

Posting children to a Structure

This question is a follow up of a previous question see: (Entry Form - Multiple Entries & Entry Type & Parent) I am trying to add multiple children to a pre-existing multi level structure: ...
0
votes
0answers
35 views

AJAX -> Plugin Controller after moving to Dev Server

I have a website running perfectly on my local machine, but throughs errors after deploying it on the dev server. So theres an AJAX call to a controller: function getListings(data) { $....
3
votes
2answers
188 views

Query entries relatedTo multiple categories in controller

I have an AJAX GET call that should count all the products matching three different taxonomies. Product families Sectors of application Liquids suitable for the product so in the form the user ...
1
vote
1answer
33 views

Craft plugin services in subfolders

So I'm getting to a point where I have a lot of services in a particular plugin, and I would like to organize my plugin services into sub-folders. I've tried a couple ways but the controllers don't ...
1
vote
1answer
501 views

Ajax call to action 404

I've a trigger on my frontend that requires an action. I've started from the businessLogic template but I'm getting a 404 and can't find why. My function public function actionExampleAjax() { ...
1
vote
3answers
327 views

Craft CMS plugin with AJAX gives 404 error

I have created a small craft cms plugin to pull some information from the DB, and everytime I execute the plugin I get a 404. Here is the controller namespace Craft; class ...
1
vote
1answer
537 views

Error 404 When trying to POST to plugin Controller action

Before I dive into my problem, I do want to mention that I did do my due diligence and spent the last two days researching this problem, to no avail, so here it goes: So I'm getting the following ...
4
votes
1answer
72 views

Store categories in array by level in controller

I'm making a plugin and I need to get an array from a certain category group where the levels of the array are the same as the level of the categories in the group. So I used the following code to ...
1
vote
0answers
41 views

Find category through ajax using ElementCriteriaModel

I'm trying to run a controller action with ajax in a new plugin I'm making. The action needs to return all categories from a group, so nothing impossible here. When I run the actionUrl in the ...
1
vote
1answer
154 views

Trouble calling a plugin's controller function from within an event listener function

I am working on extending the formbuilder2 plugin to call and pass the $event variable to a custom Controller after FormBuilder2 has initialized the "onBeforeSave" event within the FormBuilder2 ...
0
votes
1answer
102 views

How do I set a controller for my homepage

How can I set a controller for the homepage? I can't seem to find any way to override the default route to the homepage. I need to call an action from the homepage and can't find any examples of this ...
1
vote
1answer
365 views

Plugin's action URL not working and showing 404 error

I created a plugin to schedule some custom email notifications. The action URL is working perfectly on localhost but isn't working on stagings server. Is it related to any server stuff.
1
vote
1answer
79 views

No template found when accessing action method per route

I want to render a (non-CP) template from an action method in my plugin controller over a route I defined in the plugin base class: function registerSiteRoutes() { return array( 'myservice' =&...
2
votes
1answer
645 views

What should my controller return in a Craft.postActionRequest

Simple question: I made a button in my plugin settings that creates a Craft.postActionRequest but what should the controller return? It does not need to return anything else than true (successful) or ...
1
vote
1answer
229 views

Trouble passing errors back to form through setRouteVariables

This has me a bit stumped. I have two forms - posting to two different actions within the same controller. On error I am attempting to have them both display a flash-notice, as well as pass the model ...
1
vote
1answer
161 views

How do you get all the categories in a category group in a controller?

I want to get all the categories in a specific category group inside my controller. How do you do that?
0
votes
1answer
253 views

How to handle entry save in plugin when entryId is not set?

Referring to my older question, I have the entryId working on an existing entry. However I've noticed a new entry doesn't have an entryId set (makes sense). I have some custom information in text ...
4
votes
1answer
696 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 ...
1
vote
1answer
98 views

Cache controller/action

Does Craft have a built-in Controller/action for clearing the cache? We have auto-deployment set to a server and would be useful to set up a POST-receive hook to force the cache to clear when ...
1
vote
1answer
255 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/...
2
votes
1answer
264 views

Business Logic Controller for Validating Address in Commerce

I am putting together my Business Logic plugin, as I want to validate the address fields throughout the checkout process of my Cart. I understand in order to do this I need to create a plugin and us ...
2
votes
1answer
776 views

How do I call a service from my controller in a plugin?

I'm writing a plugin, and used plugin.io to generate my scaffolding. In my controller I am attempting to call a service, and getting an error. This is my service code from my generated plugin it ...
0
votes
2answers
140 views

How do I wire my form action to my controller action?

I'm writing my first Craft CMS plugin. I have the following tag in my form: <input type="hidden" name="action" value="clientnameDonation/donateForm/donate"> And then I have the following ...
1
vote
0answers
831 views

var_export does not handle circular references” when devMode = true and logDumpMethod = print_r

Here is a similar question that was asked but doesn't resolve my issue Question has changed, see UPDATE below I'm new here so I couldn't just tag a comment onto this post asking this question: I ...
1
vote
1answer
339 views

Update multiple database entries via controller

I've inherited a Craft site that is a mix of a custom plugin (the main site) plus a Laravel Dingo plugin (behind which the bulk of the data in the db lives), plus Solr, and I'm trying to untangle it. ...
2
votes
1answer
128 views

Send an asset from a plugin controller

I have a controller which fetches an asset from an entry (this is the service method that provides the asset): public function findPoster($entryId) { $criteria = craft()->elements->...
3
votes
1answer
575 views

Access data when posting to controller from front-end

I'm writing a plugin to notify authors when a Disqus comment is posted. There is a Disqus JS callback you can use to hook into this, so I'm doing the following on the front-end: this.callbacks....
1
vote
1answer
2k views

Crossdomain ajax request to controller with requireAjaxRequest()

I make request from my localhost(gulp server) to example domain in to VerifyPassword controller. When i make request without headers: {'X-Requested-With': 'XMLHttpRequest'}, It comes as expected 400 ...
1
vote
1answer
301 views

Have a custom plugin do something on every page load?

For an upcoming site build, I'm going to need to capture information on every page load for a number of sections. These will be pages based on standard entries, so I'd prefer to use traditional ...
0
votes
0answers
81 views

Why is my controller redirect failing to redirect to an existing page?

I am developing a controller for a plugin and there is a particular situation where a controller action is supposed to redirect the user to a specific URL with a status of 401. I can load the 401 URL ...
0
votes
2answers
615 views

How do I properly access plugin controllers from the front-end?

I'm building a plugin, and it all worked just fine until I decided to change the front-end form submission to use AJAX instead of submitting directly. I have a form on the front-end with this action: ...
1
vote
2answers
832 views

Does CSRF protection for controller actions require POST?

I've got a controller action which will work as the callback URL for OAUTH authentication with an external, third-party API. After authenticating, the external API will issue a GET request to my ...
0
votes
1answer
142 views

Fetch matrix field attributes in controller

In my controller I fetched the Entry $criteria = craft()->elements->getCriteria('Entry'); $criteria->section = 'offlineEvents'; $event = $criteria->first(); The Entry has a matrix field ...
1
vote
2answers
143 views

Extending UserController

I'm trying to extend the Craft UserController class, in order to add some extra validation to the actionSaveUser action, before the rest of the code in that function executes. I've got no problem ...