Questions tagged [plugin-development]

Questions having to do with constructing plugins.

Filter by
Sorted by
Tagged with
0 votes
0 answers
48 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
24 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
14 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
40 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
21 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
  • 390
1 vote
1 answer
24 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
23 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
  • 1,994
1 vote
1 answer
41 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
51 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
26 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
  • 73
1 vote
1 answer
104 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
0 votes
0 answers
22 views

What happened to preferredLocale in craft3

I upgraded to craft 3 from craft 2. My users don't have access to the control panel so I created a plugin where they can select from the front end their preferredLocale to determine which language to ...
user1535268's user avatar
0 votes
0 answers
22 views

Issue with custom field plugin - conversion from Craft 2 to 3

I have a custom field I created for Craft 2. It is a usergroup field where it will show a variety of checkboxes where an entry can be apart of multiple usergroups. The plugin has worked fine in ...
user1535268's user avatar
1 vote
1 answer
38 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
  • 161
1 vote
1 answer
24 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
31 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
41 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
  • 21
1 vote
1 answer
38 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
41 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
477 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
223 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
103 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
92 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
0 answers
18 views

Make plugin field data available via GraphQL

I have a plugin field which calculates a bunch of data according to a string value and makes it available as an object to admin and front end via the normalizeValue() method in the plugin field class. ...
thomas's user avatar
  • 131
0 votes
1 answer
171 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
38 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,315
0 votes
0 answers
119 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
  • 69
1 vote
1 answer
76 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
87 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
30 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
188 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
  • 452
1 vote
1 answer
89 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
316 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
  • 452
1 vote
1 answer
277 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
244 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
70 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
52 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
24 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
40 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
35 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 vote
1 answer
42 views

Custom plugin - show popup before element save

I've got a plugin that's got element types. I've got a Transaction element that I need the user to confirm before saving. I've tried to use the jQuery that comes with craft: $('form').submit(function(...
Pindo's user avatar
  • 203
1 vote
1 answer
67 views

Get field settings of custom field via ElementInterface

It is possible to get the field settings via ElementInterface in normalizeValue Method ? I need these settings of my custom field from my plugin : how i can get now these values inside normalizeValue ...
antdev's user avatar
  • 73
0 votes
0 answers
78 views

How to save the selected assets in custom module

I am trying to create a custom module where I have created an asset uploader field. Images are getting uploaded with that field but not saved. class Settings extends Model { // Public Properties ...
Eira's user avatar
  • 1
1 vote
1 answer
98 views

Event triggered when Craft sends email

Is there an event that would be triggered every time email is being sent by Craft? So email message can be intercepted.
Piotr Pogorzelski's user avatar
-1 votes
1 answer
90 views

how to create a custom plugin if the user enables plugin settings then it will replace the website home page to my custom design? [duplicate]

I am trying to create a plugin if the user enables plugin settings then it will replace the homepage of the website with my custom designed template
DTS's user avatar
  • 23
0 votes
1 answer
115 views

How to override homepage content through plugin?

Want to override index.twig content through a custom plugin. I want to create a plugin that appends some content on website homepage. How to Achieve this any reference will be helpful
DTS's user avatar
  • 23
1 vote
1 answer
32 views

Make plugin permission appear on permission list, without defining control panel section

How can i make plugin permission appear on permissions list, without setting public $hasCpSection = true; in main plugin class? For now i set this variable to true and then removed section link like ...
Piotr Pogorzelski's user avatar
0 votes
1 answer
234 views

Want to use assets field my template settings in custom plugin craftcms

I am creating a plugin that is based on images the admin will upload some sort of images in plugin settings not sure how to creat image field setting in plugin
DTS's user avatar
  • 23
1 vote
1 answer
99 views

Plugin logging not appearing

I am trying to log sone info on my plugins service work like below: Craft::info( Craft::t('mapitapi', 'Sleeping for 1 secs ..saved funding entry: ' . $element->id . ':' . $element->...
joomkit's user avatar
  • 1,994
1 vote
1 answer
308 views

How to batch a large queue job?

I am trying to batch a large queue job in my custom plugin. Here is my service that starts the queue. public function doBackGroundJob() { $query = Entry::find(); if (!empty($...
joomkit's user avatar
  • 1,994

1
2 3 4 5
36