Stack Exchange Network

Stack Exchange network consists of 175 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 [plugin-development]

Questions having to do with constructing plugins.

0
votes
0answers
8 views

Filter and sort commerce products based on matrix blocks

We have a website that uses Craft CMS v3.1.28 and Commerce v2.1.6.1. The below logic is implemented within a plugin and we're prepared to do custom implementations aka. prepared to go deep! This ...
1
vote
1answer
20 views

How to run function after plugin installed?

How can I run a function when my plugin is installed? I tried SafeUp in migrations but it doesn't work.
1
vote
0answers
10 views

How to fire flash messages when using Event::on()?

I'm looking to hook into an Asset::EVENT_BEFORE_HANDLE_FILE event and toss up a JS flash error if it's above a certain file size. However, the registerJs() function never runs and I assume it's ...
1
vote
1answer
24 views

Get entries based on multiple fields in controller

I am trying to get the entries based on multiple fields. Fields can be of type tags, checkbox, radio box, and number. In my controller currently what I tried is. $extrafilter will be like Array ( ...
0
votes
0answers
15 views

Rename files uploaded to certain sources in Craft 3

I have an event written for Craft 2 which renames files, which are uploaded to certain sources, to have a 35 character random string, plus its original extension. I am looking to update this for ...
1
vote
1answer
24 views

Loop through all created fields and get the field type

I want to show some input fields on frontend template form. Type of input is dependent on the type of fields selected on the backend. For example, if the text field is selected in the backend I ...
4
votes
1answer
80 views

How to order or filter entries by their author's custom field?

Is it possible to order and/or filter all entries from a section whose author has a custom field value that is set to "X"? Below is the starting code. in Twig: {% set elementQuery = craft.entries()...
0
votes
0answers
27 views

Hooking Event After Record Save

I have a custom module that is receiving data from an external API. I need to save some of that data into a record and return a success response, so far all is good. Along side this I want to set up ...
0
votes
0answers
18 views

Merge trashed element with existing one

Is there any way to merge trashed elements with an existing element? I'm creating a custom restore action so you can merge a trashed (commerce) Product with an existing one. The mergeElementsByIds ...
0
votes
0answers
37 views

How to hook into root controller to redirect any route based on some criteria?

We have a use case where if our user account has a certain flag that they are redirected to a specific page. Is there a way to hook into the root controller or some sort of router mechanism such that ...
1
vote
1answer
16 views

Craft 3 Plugin Index No Template Found

I'm looking to have a basic index page for my plugin, yet I can't seem to get index.html working for my plugin. But when I head to site.local/admin/plugin it displays 404 Template Not Found I have ...
0
votes
0answers
15 views

How to access controller method from a plugin script?

I have created a custom TwigParser which needs to execute some controller logic in a similar way to how CraftCMS's {% requirePermissionNode %} Twig parser does. Their implementation accesses the ...
1
vote
0answers
16 views

Query element api (output) via plugin

Is there a way to fetch the content generated by the Element API via a plugin. For example, if we have created an ingredients/<slug:{slug}>.json endpoint, can the data for a specific page (eg ...
1
vote
1answer
29 views

Changing some letters in entry's uri before save it

I need to replace some characters in my entry's URI because we have some letters which do not exist in English like "ş" or "ç". It is a problem for SEO and we have to change each time manually. I ...
0
votes
0answers
26 views

Category select field in custom plugin settings not saving

I am trying to show a list of categories on my plugin's settings page so an admin can select multiple categories. I am doing this with a Craft form macro: {{ forms.elementSelectField({ label: '...
1
vote
0answers
31 views

How do I correctly upload a new Asset from a temp file I generated from a service method?

Preamble Craft 3.1.26 PHP 7.2.8 on Mamp Pro 5.1.1 I browsed to my storage/reports folder and made sure in Finder than full read/write privileges are granted. What's goin on I have a module with a ...
0
votes
0answers
20 views

Custom field value doesn't get saved

I have the following code: $fieldHandle = 'contentLead'; $entryTitle = $event->element; $entryQuery = \craft\elements\Entry::find(); $entries = $entryQuery->title($entryTitle)->limit(1); ...
0
votes
0answers
36 views

Change Dropdown Value via Module

I'm looking to change a dropdown field within an entry, then save it. I currently have a lightswitch which works perfectly, but now I need to change a dropdown field. I have the following for the ...
0
votes
0answers
7 views

How do you access craft()->runController variables within the action?

I have a plugin that runs craft()->runController($actionUrl); This runs the action Controller of a separate plugin. The actionUrl contains a variables array: $actionUrl = UrlHelper::...
1
vote
2answers
27 views

Get all available fields in plugin setting page

I am trying to get all the fields created by admin in my custom plugin setting page. As we can get entries , in same way can we have option to get the available fields. {{ forms.elementSelectField({...
0
votes
0answers
12 views

Draft from front-end form with limited field set

I have a front-end form which sends a limited selection of the fields to the action entryRevisions/saveDraft (actually a custom plugin action, but in the it end up there). I expected it to take the ...
0
votes
0answers
22 views

What's the difference between `checkboxGroupField` and `checkboxSelectField` in Craft 3?

Short: What exactly is the checkboxGroupField used for? And why not just using the checkboxSelectField? Long: I am building a library that's gonna be required by a couple of my future Craft plugins ...
1
vote
1answer
25 views

Batch saving a custom field to multiple users via controller

I have to build a custom plugin for an internal user management system/data export that needs to be able to get triggered from the CP. I basically have to sort a big amount of users (1500+) in a ...
0
votes
0answers
18 views

How can I search for entries with precision in my module?

I'm working on an autocomplete Vue component for one of my Craft projects. It's very simple at the moment, all I am trying to do is have my component send a search value from the user to a controller. ...
0
votes
0answers
21 views

How can I overwrite the search page within a plugin?

My first day with Craft. I want to create a plugin that will provide a Product Query (collection, Craft Commerce) based on some 3rd party search (like Algolia). How can I overwrite the route search?...
1
vote
0answers
31 views

Sprout plugin: Send information in AJAX success response

I'm using Sprout for registering to events, I want to be able to send a code in the AJAX response when EVENT_AFTER_SAVE occurs. At the moment, I get {success: true} back, but I want to be able to get {...
0
votes
0answers
28 views

Get transformed asset URL in controller of module, while using Eager Loading

I created a module, in my controller I want to return the entries with the assets in JSON format. Here is my code. File: In service class, I am getting the data. public function getData($...
0
votes
0answers
14 views

Print to Console Inside Event

I created a CUSTOM PLUGIN and I have the following code: Event::on(FOO::class, FOO::EVENT_NAMED_BAR, function(Event $e) { $message = "Hello world"; // craft::error( $message ); // ...
1
vote
1answer
15 views

Define POST or GET for a route

Is there a way to define a route that can only receive POST data? In Laravel you can do this: Route::post('admin/content/{id}', 'ContentController@update'); Is there a way to do this with a Craft ...
2
votes
1answer
30 views

Get entries whose title has a keyword or related to a category's title

I am trying to get entries that either their title has the keyword or their category field title. I am getting them from my plugin, not twig. I tried like this: $keywordCategory= Category::find()->...
0
votes
0answers
27 views

Is it possible to use craft()->runController with variables in Craft 2

I'm trying to run a plugin 1 controller from plugin 2. I can get it to run and re-direct to plugin 1's controller but as it is not being run with posted variables I need to be able to tell plugin 1's ...
1
vote
1answer
53 views

How do I correctly send an external request to a module controller? runAction() is returning null

Craft 3.1.18 I have a simple controller VeteransController made using the updated Business Logic module. The purpose of this controller is to create a very simple endpoint for an external Vue ...
1
vote
1answer
45 views

How to cache a Guzzle Http request?

In my module I have the following: $client = new Client(['base_uri' => myBaseUri]); $response = $client->request('GET', myQueryString, [ 'headers' => [ 'Accept' => ...
1
vote
1answer
28 views

How to edit a date field in a plugin

So I want to edit date type filed on entry save, but I don't know how to format it. It times out on string and don't seem to accept DateTime objects either. Event::on( Elements::class, ...
2
votes
2answers
43 views

How do you save a new Entry to be enabled on 2+ Sites?

I've made a plugin that let's you import Entries from a CSV file and I'm working through adding localization (Sites) support to it, but I can't figure out the right way to enable an Entry for a second ...
1
vote
1answer
30 views

Custom Plugin for ZenDesk Tickets [closed]

I need all of the custom fields on an order submitted to ZenDesk to create a new ticket once the order is completed. Once a ticket is created in ZenDesk, we will need the ticket number saved on a new ...
1
vote
1answer
35 views

Craft 3 Controller - Redirect with errors

I cant get this to work. I'm doing a post to a controller action. From that action I'm doing a lot of validations, db insert, file uploads etc. Coming from Laravel Im used to is doing like this: (...
2
votes
0answers
37 views

Creating multiple plan subscriptions

Versions: - Craft CMS (3.1.21) - Craft Commerce (2.1.2) - Stripe for Craft Commerce (1.2.0) Problem: - My website offers user's ability to subscribe to several subscriptions at the same time. ...
1
vote
0answers
46 views

What's the most performant way to get reverse related entries within an Element Query?

What's the most performant way to get reverse related entries within an Element Query? Here's a contrived example of this. I have thousands of "book" entries and thousands of "collection" entries. I ...
1
vote
1answer
20 views

Get HTML of rendered template inside module

I'm getting started with plugin/module development. I want to get the template file, pass some variables to it, and get rendered HTML of that template into a string variable. How do I do that?
1
vote
0answers
32 views

Custom plugin: Creating new fields will delete the field group they're being created in

I have a simple plugin which reads in a CSV file, and based on the first row of data will create a new field group, and then create fields within that group. The first time I run it everything goes ...
1
vote
1answer
19 views

Possible to reflect changes to a plugin's composer.json without uninstall/reinstall?

When working on a plugin recently, I decided to add a CP section: composer.json { ... "extra": ... "hasCpSection": true ... } The only way that I was able to have this ...
1
vote
1answer
21 views

My plugin settings page is never loaded

I have been staring at this all morning, comparing to other plugins online and cannot see why my plugin settings page never registers. I have verified the actual settings model is populated, but ...
1
vote
1answer
31 views

Updating private repo plugins from admin?

Is it possible to update private repo plugins from the admin at all? Would love that functionality, especially for smaller projects that are installed where there's no CLI access.
1
vote
1answer
31 views

How to set stability version in plugins?

I've made a plugin, that I'm now trying to include in a live project, but when I try to install it via the plugin installer, I get a 500 error, and if I try to include it using composer, I get the ...
1
vote
1answer
43 views

Order Adjusters in Commerce 2

In Craft Commerce 1, there is documentation on how to re-order adjustments that do similar things. https://docs.craftcms.com/commerce/v1/adjusters.html#ordering-adjustments But I don't see any ...
1
vote
0answers
22 views

Custom Element Reference Tags

I have created a custom element type and cant get the reference tags to parse correctly, I've set the refHandle and the action to copy reference tag which seems to be correct format when I copy a ...
1
vote
1answer
66 views

How to pragmatically set registered user status to pending and then manually send activation email

I have 2 front end registration forms. One for normal users and one for admins. In each form I have a hidden input with a group value like so: <input type="hidden" name="group" value="ypo"> In ...
1
vote
1answer
72 views

Ajax Post to Plugin Controller

I have been stuck on trying to make an ajax call to a custom plugin controller in Craft 2 for a few days after trying everything from following the documentation for Craft 2 as well as looking up ...
1
vote
1answer
22 views

Plugin not updating in the plugin store from changelog updates

I have a custom plugin registered with id.craftcms.com. The plugin store currently sees it at as 2.0.0, but I have since updated the plugin to 2.0.1 (and subsequently tried to force a silent 2.0.2 ...