Questions tagged [plugin-development]

Questions having to do with constructing plugins.

Filter by
Sorted by
Tagged with
1
vote
1answer
8 views

Craft 3 replacement for the Craft 2 fileCache component?

I'm upgrading a plugin from Craft 2 to Craft 3 and it looks like the fileCache component is no more. What has replaced it in Craft 3?
1
vote
1answer
21 views

Use sidebar nav icons in modules and plugins

When adding a navigation item, there is the option to specify an icon, but it seems to have to be a path to an SVG. I can see that Craft has its own icon library, and it has an icon I want to use. I ...
0
votes
0answers
18 views

ElementAPI: How to trigger the Custom service php file when a endpoint is loaded

I am Using Craft 3.3.11 version I have a php file in plugin/elementapi/src/services/EapiServices.php and the same file within vendor/craftcms/element-api/src/services/EapiServices.php When ...
0
votes
0answers
16 views

Save and log in a user from event callback

I'm trying to build a plugin wherein after a user is created via the normal means via a front end template, the user is immediately logged in. My module is watching for the after save event on ...
1
vote
1answer
37 views

Frontend form validation

I need to validate the form submitted at the frontend by applying additional validation rules. For that I have created the plugin that listens to "EVENT_BEFORE_SAVE_ENTRY" event and should validate ...
0
votes
0answers
17 views

Create an entry type on plugin install

When a user installs my plugin, I would like the plugin to create an entry type on install. First of all, is this possible? If so, can someone point me in the direction of where I would find ...
1
vote
1answer
12 views

Craft 3 plugin - how to update entry with field of Entries type

Using PHP, I want to update a field of Entries type of an existing entry. Fields of type Text and Number will update with the following code: $entry = Entry::find()->id($entryId)->one(); $...
0
votes
0answers
13 views

Cannot declare class TwigTransformer, because the name is already in use

Within the source code of my plugin I needed to check if another plugin was installed. To do that, I needed to access plugins class. What is the difference between: class Something{ public ...
1
vote
0answers
9 views

Conditionally attach behaviors to craft\elements\Entry by section

I'm trying to conditionally attach behaviors based on an entries section. The following code works fine, but I'm trying to clarify one bit: To avoid a yii\base\InvalidConfigException on the CP ...
0
votes
0answers
25 views

Contact form plugin ajax submit URL not working

I am using contact form plugin for forms in my craft website. For avoiding page redirection, I followed ajax submit for the form, but it is not redirected to controller code. My form is as below:- ...
1
vote
0answers
11 views

Modify preview targets and save them

I'm using the following Event hook : Event::on(Entry::class, Entry::EVENT_REGISTER_PREVIEW_TARGETS, function ($event) { } The $event variable contains an array with the current $previewTargets as ...
0
votes
1answer
27 views

How to identify the recurring payments that happen after the initial subs creation payment the in Commerce Subs

I've got a custom module that I have written to inject data into various places in my site when events happen with Commerce Subs. As per the question title, I need to update an entry when a recurring ...
2
votes
2answers
48 views

Trigger FeedMe import from plugin

I'm importing Real Estate properties every 30 minutes into my website. I have a controller action that triggers this but the import is extremely slow and blocks the entire site. Right now I'm ...
1
vote
1answer
36 views

Craft 3 - Plugin - Override Control Panel column values for field or field types

How can I override the column value for a plugin in the Craft CMS control panel? For example: Append "Hello " in front of a particular column value, or add hyperlink HTML markup to a value, in each ...
2
votes
1answer
29 views

Craft 2 FormBuilder 2 equivalent plugin in Craft 3

Is there any plugin equivalent to Craft 2 FormBuilder 2 plugin in Craft 3? My Craft 2 website forms are built with FormBuilder 2. I upgraded the website to Craft 3, but FormBuilder 2 is not working. I ...
2
votes
1answer
35 views

Finding the correct actions url

struggling to decipher how to link a plugins controller to an action route. The docs say to use "https://pluginfactory.io/" to scaffold one, but what it generates is a different structure to what the ...
1
vote
1answer
27 views

“Redactor plugin not found” – How to properly implement Craft plugins providing Redactor plugins?

TL;DR What is the correct/recommended way to implement a Redactor plugin within a Craft plugin? My intention I'd like to implement a Craft CMS 3 plugin that adds a new Reactor plugin. Normally (...
3
votes
1answer
63 views

Restrict Sources on element select field

I'm building a module with a form that includes an element select field that I want to restrict to specific volume. So far this is what I have: {{ forms.elementSelectField({ label: "Asset"|t('app'...
0
votes
0answers
19 views

Craft 3 match all categories using relatedTo in a module controller

I am trying to perform an entry query using relatedTo to get entries that match all categories. I know how to achieve this with 'and' in twig but I can't seem to find the correct syntax to use in a ...
0
votes
0answers
9 views

Commerce preferred currency - user/customer setting

Is there a way for users/customers to set a custom/preferred currency that would be applied to any future carts (assuming more than one currency was available)? Was looking at whether could do this ...
1
vote
1answer
38 views

Redirect to template from controller and pass data

I am building a custom login process which follow these steps: Request user email (submits to custom controller) Check if user has an account If they have an account, show a form requesting their ...
0
votes
0answers
36 views

How to get current site (locale) api / plugin

For my form plugin I'm using a global set of fields. These can be set in 2 languages default and en. Problem is whenever I try to output them I cant dynamically make them use the current site locale/...
1
vote
1answer
29 views

Calling Craft Console Commands from Plugin?

I am in the process of building a plugin that has a controller that accepts a HTTP request. If the token and request are valid, I would like to call a Craft Console Command from within the plugin (e.g....
1
vote
1answer
25 views

Accessing named parameter in custom route from within a controller

I have a custom module in which I am setting a front end route that routes through to a controller. Like so: Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_SITE_URL_RULES, ...
1
vote
2answers
43 views

Eager loading category data from a Matrix block

How might I eager load category data in a plugin? I can't seem to figure out why I can't access a category in this way: locationOffers is a matrix block name, category is the handle of a related ...
1
vote
0answers
24 views

How can I override the Response status text from a controller?

I'm trying to set the statusText in a response, from a module controller. E.g.: <?php namespace modules\appmodule\controllers; use Craft; use craft\web\Response; class StatusController extends ...
0
votes
0answers
25 views

V3 Plugin to check user is new and skip email activation

I am new to craft development. I have a client looking to whitelabel their existing site but have new users added to a group and then be directed to a sub site of theirs. So, I am looking for a way ...
2
votes
1answer
27 views

How to get users with birthday today in plugin/module?

How does one retrieve users from Craft3 DB whose birthday is today? Birthdate field type is Date/Time. Have a working PHP/MySQL example, but unsure how to port this to Craft3 syntax. $sql = '...
1
vote
2answers
28 views

Doing something with the success response from a Webhook

Craft Webhooks is great for sending one POST to a service... but if you need to parse the response from that hook... is there a way to do that? I can't see it as any option in the plugin, and I can't ...
1
vote
1answer
22 views

Programatically add lines to a Super Table field

I am trying to add new lines into a SuperTable field of an entry from my plugin. Following the Developper sample, I am able to change set lines to this SuperTable field. But it is replacing the ...
0
votes
1answer
20 views

Plugin RegisterUrlRulesEvent - cannot find Controller aciton -> 404

The error I'm getting: HTTP 404 – Not Found – yii\web\NotFoundHttpException Page not found. ↵ Caused by: Invalid Route – yii\base\InvalidRouteException Unable to resolve the request "Expedweather/...
0
votes
0answers
21 views

Better way to manage local plugin in git

Not 100% Craft only, but I have a question on how best to manage code in git. I have a site and a plugin (only for my use), and I've just been doing some major revamp to the plugin, more or less a new ...
1
vote
1answer
35 views

Plugin RegisterUrlRulesEvent - Regex URL-Routing gives 404

I'm updating a Craft 2 plugin to Craft 3 and I'm having difficulties getting the Regex URLs working correctly. The eocs I'm using: Craft3 Docs I used pluginfactory.io to create the basic craft3 ...
1
vote
1answer
69 views

Headless Craft CSRF

I have a site that is using Craft CMS headless and React. There are a few forms that need to post to controllers but I'm not sure how to set up the CSRF tokens and keep it secure. Can anyone advise ...
0
votes
0answers
16 views

Sort entries by related element in plugin

I am using a plugin to fetch Entry elements based on various criteria (eg to produce an array based on \craft\elements\Entry::find()). The section I am querying features a number of related ...
0
votes
0answers
28 views

Custom plugin - how to save settings featuring array?

I'm developing a custom plugin but hitting an issue when I want to save a settings that uses the multiSelect, checkboxSelect or checkboxGroup fields (essentially any field that saves values as an ...
1
vote
2answers
41 views

In a plugin, how to get entry status?

This seems like it should be simple to find, but where does Craft store the status of entries (lightswitch for enabled/disabled)? It doesn't seem to be a column in the entries table, and I can't ...
0
votes
0answers
18 views

EntryModel as model attribute doesn't get populated as model

I've created this custom plugin with a CP interface for a website running latest version of Craft 2. Each record in my custom table relates to an entry using an entryId. I've set up all the records ...
1
vote
1answer
26 views

Custom field plugin: Unable to find template / General custom field plugin information

I am still relatively new to Craft CMS. I am trying to make a custom field plugin for Craft 3 but I am struggling to understand why I can't render my form template. The fieldtype should render a map ...
1
vote
1answer
25 views

What is the appropriate way to query and Hard Delete existing Soft Deleted Elements for a Custom Element?

I have a Custom Element where the Soft Delete functionality is not necessary. Right now, existing users of this plugin may have thousands of Soft Deleted Elements in their Elements table that don't ...
3
votes
1answer
40 views

Entry element query missing user field data when user is suspended

I have a channel in which each channel entry has a "users" field type that is limited to one user. My code below works fine when the user is not suspended, however if I suspend the user, the then $...
1
vote
2answers
75 views

Send email with dedicated SMTP settings from a Craft 2 plugin

I have looked a lot for this but cannot find any dedicated solution. Basically I want to do this: How to send email from Craft 3 custom plugin? … but for a Craft 2 plugin. A how-to for the global ...
0
votes
0answers
27 views

Geocode address when saving custom field type in plugin

I've got a Craft CMS 3 plugin that has a custom field type for entering an address. When saving that field I'd like to take that address and geocode it using Google's Geocode API and save the latitude ...
0
votes
0answers
25 views

Is it possible to send Solspace Freeform mail with custom module?

I'd like to send mails from my custom module for Craft. But instead of Craft I want to use Solspace Freeforms plugin. Is it possible to send mails with this plugin outside of frontend?
0
votes
0answers
30 views

How to use a table field in custom plugin's settings (Craft 3)

I need a table field in my plugin's settings, but when I make 2 rows and save the settings, only the first row is shown when I go back to the settings page. When I dump the values, my second setting ...
0
votes
0answers
8 views

AssetBundle-related when installing a plugin via console and not via Cp

I have a plugin which registers an AssetBundle. The asset bundle itself is quite basic and only includes one JS-File. In the init() method of my plugin, I register the bundle: // registering the ...
2
votes
1answer
68 views

How do I get the Site/Revision/Draft in a field in the control panel?

Is there an easy way to fetch the selected Site, Revision and Draft of the dropdown (the one an editor would use to switch the Site/Revision/Draft) in control panel in a plugin? The only way I found ...
1
vote
1answer
21 views

Module Development - Get ID of a field within a Matrix field

I have a matrix field that has a Supertable matrix within it. I need to programatically get the ID of the field that is nested in the Matrix. I have the code below: $matrixField = Craft::$app->...
0
votes
0answers
14 views

Fetch the entries based on local time zone

I am trying to fetch the entries based on the local timezone. $entries = Entry::find(); $entries->section('news'); $timezone = new \DateTimeZone(Craft::$app->getTimeZone()); // current site ...
1
vote
1answer
63 views

$event->isNew not working as expected after Craft 3.2 update

Pre Craft 3.2, you could do something like this if you wanted to perform an action in the event you just saved a new entry: use craft\elements\Entry; use craft\events\ModelEvent; Event::on( ...