Questions tagged [plugin-development]

Questions having to do with constructing plugins.

Filter by
Sorted by
Tagged with
0
votes
0answers
15 views

Read File from Main Plugin Page

I'm new to plugin creation for Craft 3 and currently stuck trying to read the contents of a JSON file. I can manage it fine from the Settings page using: protected function settingsHtml(): string ...
0
votes
0answers
22 views

Remove an entry's parent via a Craft Plugin or Module

I'm trying to remove/unset the parent from a module, according to the docs it seems like this method should do it: https://docs.craftcms.com/api/v3/craft-base-element.html#method-setparent. However, ...
0
votes
0answers
12 views

Paypal Express, Commerce 3.0, more information on Paypal Invoice

Using Craft 3.4.9 and Commerce Pro 3.0.11 What's the best way to get more information onto a Paypal invoice so that I can match Paypal data with a Craft Commerce order? Does anyone have some success ...
1
vote
1answer
15 views

Not triggering SEOMatic on save element

I'm writing a module that loops over lines in a CSV file to save them as entries. For every entry I save with elements->saveElement($element);, SEOMatic will queue a job that regenerates the ...
1
vote
1answer
18 views

Add new error to macro errorList - User Registration

Using CraftCMS example registration form in the docs. How would I add a new error message to the macro errorList in the registration form: {% macro errorList(errors) %} {% if errors %} ...
0
votes
0answers
10 views

How do I allow partial payments?

The closest thing I found to what I need is here, the problem is, even though it's only 8 months old, it appears outdated. I see there is an "outstanding balance" in the PayController, but I have no ...
0
votes
0answers
32 views

How to move a plugin from dev to prod?

I have a plugin that I developed in a symlinked folder locally. I now want to deploy it to production. But when I do composer require namespace/pluginhandle it gets symlinked. What I want is to ...
0
votes
0answers
21 views

Update category selection in user custom fields

I have a Category "Colors". This category has: Blue, Red, Green I've added a custom users field (CP > Settings > Users > Fields), this field is the category type. "Colors". In the front of website I ...
1
vote
1answer
41 views

PHP warning with composer on MacOS Mojave: Failed to open stream: No such file or directory

I am working on a plugin in Craft:3.4. I get this error while trying to install the plugin in the CP. yii\base\ErrorException: include(/app/vendor/composer/../wittsstratts/craft-company/src/Company....
0
votes
0answers
16 views

Extending Craft controller classes and using private methods in child class

I created Controller that exptends Craft AssetsController. Hovewer some of AssetsController methods are private - and I cannot use them using $this context in child module, so i just copied them to ...
1
vote
1answer
19 views

Sending an e-mail to current user in FeedMe hook

I have made a custom module that allows a user to upload a CSV and import it using a FeedMe feed. This all works fine, however I want to send an e-mail to the user when the import has completed. I ...
1
vote
1answer
14 views

How do I store and retrieve elements for ElementSelectField? Getting error “Call to a member function getUiLabel() on array”

I have a field that allows a user to select multiple products and save them to the database for a plugin, but when I try to retrieve these values and have them selected in my form I get the error ...
1
vote
1answer
24 views

Cannot call service: “'MyPlugin' not found” error

I'm sure this is a trivial mistake but I can't figure it out (first-time plugin dev). I have my plugin running with all code in the controller and want now follow best practice and move the workhorse ...
1
vote
0answers
29 views

How to save dynamically created checkbox values in plugin settings?

I am in the early stages of developing a plugin for Craft 3. In its settings it should have a checkbox for each section the user has defined that enables the admin to select or unselect each section ...
1
vote
1answer
9 views

Getting adjustment amount in a plugin

I need to get the amount of a discount from orders to write that data into a json file (on EVENT_AFTER_COMPLETE_ORDER) which then will be consumed by an inventory management system and now am stuck ...
0
votes
0answers
28 views

Editing a users custom fields from a plugin action Craft 3

Does anyone know if there is a block on updating users form an action? Trying to update a users custom field in craft 3 via plugin in the admin. The admin template calls an ajax call to the action ...
1
vote
1answer
31 views

RegisterUrlRulesEvent rule to display site page

Within a plugin I have written I would like to route POST requests to the plugin controller and GET requests to a single entity created in craft. When the user POSTs to http://example.com/start-your-...
0
votes
0answers
25 views

After calling the controller method error from template. Craft CMS 3

https://prnt.sc/qqs50o I use the base plugin template from plugin factory.
2
votes
1answer
47 views

How can I write a PHP script to zip and download an Assets subfolder?

I've searched everywhere but can't seem to get a straight answer. I want to write a php script to zip and download an entire subfolder in my assets directory. The subfolders are named based on a ...
1
vote
1answer
21 views

How can I access the Gateways services?

I have been trying to access craft\commerce\services\Gateways; from a plugin but I can't figure out how I need to access it. I've used the following: $gateways = Commerce::getInstance()->commerce-&...
1
vote
1answer
15 views

Updating global set from controller

This is my code: $giveaway = Craft::$app->globals->getSetByHandle('promotions'); $giveaway->giveawayName = "New Name"; $success = Craft::$app->globals->saveSet($giveaway); return($...
1
vote
1answer
24 views

\ns\prefix\Plugin::getInstance() returns null from another plugin in Craft 3

I'm building a plugin that extends the functionality of the Contact Form Tuner plugin and customize the email recipients based on different scenarios. The email addresses need to be managed in the ...
1
vote
1answer
40 views

Choose not to save an element on EVENT_BEFORE_SAVE_ELEMENT

I want to do some server side checks to see if the entry should be saved or not. In my plugin I have something like that Event::on( Elements::class, Elements::EVENT_BEFORE_SAVE_ELEMENT, ...
0
votes
0answers
20 views

Craft3 DateTime is updating todays date on element save

I have an issue where my new element is saving with the current date and time. I won't want it to save with any kind of date/timestamp. Does craft just automatically put in the current date and time ...
1
vote
1answer
14 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
42 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
22 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
22 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
46 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
20 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
64 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
17 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
29 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
33 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
23 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
39 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
75 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
42 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
43 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
41 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
43 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
67 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
24 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
11 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
65 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 ...
2
votes
1answer
56 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
97 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
44 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
62 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
30 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 ...

1
2 3 4 5
33