Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [plugin-development]

Questions having to do with constructing plugins.

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

Save field value After Complete Order

I am using Craft Commerce and want to edit the order after it has been completed by the customer. For this I am using the EVENT_AFTER_COMPLETE_ORDER event. Event::on( Order::class, ...
Matthias's user avatar
  • 301
2 votes
2 answers
49 views

Reference SVG file in CSS of custom plugin

I have built a custom plugin and have a css file that is being injected as an assetbundle. This works great but when I want to set a background image (SVG in this case) I'm not sure what the path ...
Matthias's user avatar
  • 301
0 votes
0 answers
23 views

Multiple Plugins Sharing the Same PHP Includes

Is it possible for multiple plugins in Craft 2 to share the same PHP Include file? If so, where would the shared file need to be located? Thanks
buck1112's user avatar
  • 400
0 votes
0 answers
21 views

How to create a matrix style field in a custom plugin

I'm building a custom plugin for Craft CMS 4 that has a form where users can add and remove a list of products. Every product has a title and a price field. Other fields have been created like this: {{...
Matthias's user avatar
  • 301
0 votes
0 answers
34 views

Adding attachment to system message with getMailer and composeFromKey

I have already created a new system message called after_new_submission -- all good there. Now, I'm trying to use that system message AND add an attachment. Here's what I've tried below, but the error ...
Dario Zadro's user avatar
1 vote
1 answer
32 views

How to get field values by specific field type from all Entries?

I am trying to get all values of a specific field type from all entries. (ex.: craft\fields\PlainText) Is there an easy way to get these values ?
antdev's user avatar
  • 137
1 vote
1 answer
36 views

Can't remove custom plugin

I have removed all references to the plugin in the DB and the codebase. The plugin is currently displayed as "Not installed" in the plugins admin panel. When I try to remove it by clicking ...
Matthias's user avatar
  • 301
1 vote
1 answer
59 views

What is the best way to automatically add a job (queue) every day?

I would like to add a daily job that updates data. I have the following code: Event::on( Controller::class, Controller::EVENT_BEFORE_ACTION, static function (ActionEvent $event) { ...
antdev's user avatar
  • 137
1 vote
1 answer
51 views

Find all Users with a Custom Field Value in a Plugin

Spent a good amount of time trying to return all Users that match a custom field value. Reading the docs here, it shows a findAll() command. However, when trying the code below, it's not working. use ...
Dario Zadro's user avatar
1 vote
1 answer
41 views

Same File Shared By Multiple Plugins

I'm working in Craft 2, and was wondering if there is a way to share the same file among all of my plugins? Each of the plugins will be reading the same XML file, and, currently, I've only been able ...
buck1112's user avatar
  • 400
1 vote
1 answer
67 views

Tables not created when plugin installed

I've got a plugin that works on Craft 4.5. It's been installed a long time, upgraded from 2.x to 3.x. Now trying to use it on a new install of Craft 4.5.10, installing it does not create any tables. ...
kr37's user avatar
  • 1,355
2 votes
1 answer
46 views

Calling a Function From Private Plugin

Writing my first plugin. Scaffolded with Generator and is active (appearing in admin). This is where most tutorials leave you on your own so hoping to get some help calling a simple function in my ...
Jason McKinney's user avatar
1 vote
1 answer
48 views

Can plugins have their own routes?

I'm writing a plugin. I'd like it so that a request to view the page is processed via a Controller rather than goes straight to a template (following an MVC pattern). So a GET request to the URL of ...
Chuck Le Butt's user avatar
1 vote
1 answer
92 views

In Craft CMS CP plugin, how can I intercept the lightswitch.php getTableAttributeHtml?

I'm trying to make a basic plugin that intercepts Lightswitch.php and edits getTableAttributeHtml Here is the current way: public function getTableAttributeHtml(mixed $value, ElementInterface $element)...
coydecoy's user avatar
0 votes
0 answers
37 views

In Craft CMS CP plugin, how can I get the current entries relevant to the view I'm on? Trying to edit the Lightswitch field for all entries

In Craft CMS CP plugin development, How can I get the current entries relevant to the view I'm on? Event::on( View::class, View::EVENT_BEFORE_RENDER, function ($context) { $entries = ...
coydecoy's user avatar
0 votes
0 answers
18 views

Whats is the correct way to save and retrieve an entry or assets in a custom record?

Let's say i have a custom ActiveRecord and want to save a single Asset or an Entry relation (one to one) inside one of it's columns, what's the correct way to do this?
user14370's user avatar
1 vote
1 answer
106 views

Custom Element Type Documentation not working or confusing

Following the docs on the offical CraftCMS website i'm not able to get "Native Layout Elements" saved. My field body is always empty. Any idea what i'm missing here? Relevant Part of Plugin ...
user14370's user avatar
0 votes
2 answers
31 views

Craft 2 Caching RESTful API Results Displayed On Page

I have made a php plugin in Craft 2 which calls a RESTful API and displays the results on the template. The data is returned at about 8 seconds. I've surrounded the call to the plugin on the ...
buck1112's user avatar
  • 400
1 vote
1 answer
38 views

Is there a way to determine an element by its path or full url instead of the uri?

I'm using Craft in headless mode. It's a multisite setup different languages. I know that's it's possible to query an element by it's uri. Is there a way to check if a full path or an absolute url ...
user14370's user avatar
1 vote
1 answer
29 views

Plugin migration - how to handle count in php8.1

I am trying to migrate a plugin from Craft 3 to Craft4 . The plugin basically checks the entry for a pdf asset and create a thumbnail asset from the PDF using Imagick to save with the entry. I use to ...
joomkit's user avatar
  • 2,024
1 vote
1 answer
61 views

Craft CMS 2 - Exporting entity issue

I installed this https://github.com/boboldehampsink/export plugin but getting error during exporting entities regarding to "count(): Parameter must be an array or an object that implements ...
Nik Dev's user avatar
  • 13
1 vote
2 answers
89 views

Entry url in console action doesn't return absolute URL

In an e-mail template in a custom plugin I want to render a link to an entry. This needs to be an absolute URL. I need this to work both when triggering the action from the control panel, and when ...
PWL's user avatar
  • 157
1 vote
1 answer
35 views

How to make checkboxSelectField sortable?

i am trying to make checkboxSelectField sortable so far i have only managed with inclusion of third party scripts (sortable in jquery.ui). The code looks like this: Twig: {% import "_includes/...
antdev's user avatar
  • 137
1 vote
1 answer
135 views

Craft 4 Building a Plugin not saving all properties

After following the "How to build a plugin" from the official CraftCMS docs, I've started extending the Control Panel Template from 1 to multiple fields, all are of the same type string and ...
funkysoul's user avatar
  • 113
1 vote
1 answer
57 views

How to check read-only mode in plugin?

I have written a plugin and it listens to different events to run some tasks. Now if the app is in "read-only mode", I do not want some of these events to run: class MyPlugin extends Plugin {...
7ochem's user avatar
  • 165
1 vote
1 answer
25 views

Editing users preferredLocale from a plugin controller

Recently upgrade from Craft 2 to Craft 3. Also had to update all the custom plugins. Once of them is to run a daily import of users from a file. In that file we try to set the preferredLocal of that ...
user1535268's user avatar
1 vote
0 answers
34 views

How to detect when a custom Field's element is being hard deleted?

With a custom Field how do you detect before the element associated with the field is hard deleted not just before it is soft deleted (beforeElementDelete) and added to the trash.
a-am's user avatar
  • 2,857
0 votes
1 answer
48 views

Deleting a matrix block type that was copied in code

I'm somewhat new to Craft, and struggling a bit with copying matrix block types. Any help would be greatly appreciated. So, I have some code that copies a matrix block and its fields, but when I go to ...
Eli's user avatar
  • 31
1 vote
1 answer
52 views

Entry Query: How to load an entry with the full URL as only criterion

From PHP (Plugin), how can I load a certain entry if only the full URL is provided? I can not find Craft's logic in PHP to split the full URL into the site's baseUrl and the entry's URI. Please note ...
Matthias Redl-Mann's user avatar
1 vote
1 answer
54 views

Create a template for front end when plugin install

I have a plugin which embed a forum to front end website. For that i need a .twig template file to be created when craft admin install my plugin. The template file will have html code <div id="...
Kishan Mistry's user avatar
1 vote
1 answer
877 views

Using EventStream doesn't work because MimeType from Controller Action is always text/html

I'm trying to listen to SSE events from a controller action. I am setting the headers in the controller action with: Craft::$app->response->headers ->set('Content-Type: text/event-...
Tudor-Radu Barbu's user avatar
1 vote
1 answer
449 views

Updating to Craft 4 breaks plugin settings: must not be accessed before initialization

I maintain a plugin. Inside this plugin's composer.json, extra>handle is set to pizza (not the real name). In one of the controllers, the following code is executed: $apiKey = Plugin::$plugin->...
Paul Hübner's user avatar
1 vote
1 answer
181 views

How to programmatically create category groups and categories in Craft 3/4

I am struggling to create a new category group and category programmatically. I've found a few examples for creating an entry, and one for creating categories in Craft 2, but I can't get it working in ...
Garrett's user avatar
  • 417
1 vote
1 answer
174 views

Best way to create forum using CraftCMS 4

I'm currently develop a website using CraftCMS 4 and one part of it is forum, where users can ask and answer questions. What is the best way to create it? I've found a plugin "Website Toolbox ...
Alex Kuzmin's user avatar
0 votes
1 answer
182 views

How to update Craft 3 version of plugin when Craft 4 version is already released?

I have a plugin that initially was created for version 3.x of Craft, but was updated to be compatible with Craft 4. How can I update the plugin with some new features for Craft 3?
Piotr Pogorzelski's user avatar
2 votes
2 answers
46 views

Plugin 'editableTable' settings field returns incorrect type when empty

My plugin uses a {{ forms.editableTable({...}) }} field within the settings.twig. When the field has row items it will save just fine, but when the table is empty it attempts to save it as an empty ...
Mark Notton's user avatar
  • 2,337
0 votes
0 answers
144 views

How to send e-mail on an event

I was wondering how to send an E-mail after an event. In this example I'm using stripe payments and I want a mail to be send after a transaction was completed. Below I have tried to send a mail when a ...
aren's user avatar
  • 79
1 vote
1 answer
90 views

How to set up webhooks individually for each site in multi-site configuration with many customers?

The current issue is that I have multi-site setup, where are many different sites in a single Craft instance, e.g., I have 10 websites from 10 customers, when one customer updates his website I want ...
Vladimir Andrianov's user avatar
2 votes
1 answer
128 views

Adding section to Graphql "View - Public Schema" programatically

So, I am creating new section called "My Section" with handle "mySection" via plugin. All good there. I want to be able for my section to be Viewable via Public Schema each time it ...
b.doe's user avatar
  • 23
1 vote
1 answer
41 views

Reordering Matrix blocks by date in the control panel when saving an entry

I'm trying to reorder Matrix Blocks in date order when saving an entry in the control panel. I kind of have it working using the following code. My Matrix field is 'events'. Each block contains a date ...
Lewis Jenkins's user avatar
1 vote
1 answer
315 views

How to add and run migration from plugin root folder?

I'm trying to add a new table to an existing plugin. I can't add it to the Install migration as I want existing installations to pull the change. The problems I ran into: I can't run Craft CLI (php ...
Matanya's user avatar
  • 472
1 vote
1 answer
116 views

Craft 4 - Upgrading Plugin to support Condition Fields

I've got a plugin that uses field layouts. I was asked about Craft 4 Conditional Field support so I went away to investigate. From what I gathered so far, the toggling of conditional fields happens ...
Sean Delaney's user avatar
2 votes
1 answer
446 views

Craft 4: How to programmatically attach fields to entry type tab

I'm in the process of upgrading a plugin from Craft 3 to Craft 4. When the plugin is installed it creates some fields and attaches them to an entry type. The way it was done in Craft 3 is: Get the ...
Matanya's user avatar
  • 472
1 vote
1 answer
393 views

Getting column not found when using 'Entry::find()' to find the matching channel entry in custom plugin

We are building a plugin to perform some custom operations with an ERP system. We created a section for managing the users from ERP. We are able to create new users as channel entries and update them ...
Market South's user avatar
1 vote
1 answer
357 views

What's the correct way to check that an asset file exists?

If I have an asset resource, loaded successfully from the database, whose corresponding file no longer exists on its Volume (irrespective of Volume type), what is the best way to find out if the file ...
tomkiss's user avatar
  • 43
1 vote
1 answer
105 views

Can't access Cookie from controller in plugin

In the frontend my website sets a cookie wich i need during a controller action. When calling the controller action from my plugin this Cookie gets duplicated and the value is replaced with an ...
Mathies Gielen's user avatar
1 vote
1 answer
74 views

Feed Me Plugin - Prevent Feed from Being Triggered Multiple Times in Quick Succession

I’d like to prevent a feedme feed from running more than once when multiple requests are received within a few seconds of each other. My first guess is that I would want to target an event such as ‘’’...
Chris Drew's user avatar
1 vote
1 answer
28 views

User profile - if user logs out after saving an Asset - Invalid subpath “profile/{{currentUser.id}}” - SSO Login fails

Having tested this error only occurs while using the SAML Service provider plugin: I have tested in multiple versioning env and experienced the same issue. I can save an asset file Image or doc while ...
Joshua's user avatar
  • 11
1 vote
1 answer
45 views

Can't change author and dateCreated/postDate on duplicate entry action in Control Panel

We have a Craft-based email campaign builder that is up to date with Craft 3.7.x and plugins. I have a business logic plugin that works for a lot of custom functions but I can't seem to get this going....
Chad Crowell's user avatar
1 vote
1 answer
44 views

Is there a way to trigger a user account creation from a different CMS?

I'm a junior web developer working with Craft CMS. I was wondering if there was a way to trigger a controller I have for my Craft CMS from an outside CMS. We have more than one website that offers ...
wannabecraftwiz's user avatar

1
2 3 4 5
36