Questions tagged [plugin-development]
Questions having to do with constructing plugins.
1,738
questions
1
vote
1
answer
18
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 ...
1
vote
1
answer
37
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 ...
2
votes
1
answer
38
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 ...
1
vote
1
answer
36
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 ...
0
votes
0
answers
14
views
DB Query from specific section
I have a website running on craft 2 and I am having trouble with creating queries in a custom plugin controller.
I have a section "tasks" and custom field "ordernr". From the ...
0
votes
0
answers
56
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 ...
0
votes
0
answers
17
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 ...
1
vote
1
answer
25
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 ‘’’...
1
vote
1
answer
15
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 ...
0
votes
0
answers
13
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....
1
vote
1
answer
25
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 ...
1
vote
1
answer
29
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(...
0
votes
0
answers
27
views
Craft Commerce attributes
I was looking for the way to make something like this with Commerce variants:
and the only solution that I found is this tutorial:
https://www.vaersaagod.no/en/multi-attribute-variant-selection-in-...
0
votes
0
answers
24
views
Error - Job must be a JobInterface instance instead of __PHP_Incomplete_Class
When I try to run a custom queue job on craftcms, it fails every time and I got this error Job must be a JobInterface instance instead of __PHP_Incomplete_Class, I'm pretty new to craftcms and even ...
1
vote
1
answer
16
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 ...
0
votes
0
answers
33
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
...
0
votes
0
answers
23
views
Craft 2 Manually Rendered Template - Logic
I'm currently working on a plugin in Craft 2 that will load entries into Ajax and then output to a template, one entry at a time, controlled perhaps by javascript window.setTimeout to advance to the ...
0
votes
0
answers
26
views
What's the recommended approach for applying effects on images and saving them in the respective volumes?
I'm creating a plugin in Craft CMS and it has a feature where you can apply certain image effects and after you are done, you can save it in the configured Asset volume. I know that ImagerX also does ...
1
vote
1
answer
43
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.
-1
votes
1
answer
76
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
0
votes
1
answer
74
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
1
vote
1
answer
16
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 ...
0
votes
1
answer
96
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
1
vote
1
answer
23
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->...
1
vote
1
answer
80
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($...
0
votes
0
answers
39
views
Why is my queue in custom plugin failing on VPS but not locally?
I am working on a background job in a custom plugin.
On my local Laravel Valet setup it runs fine until it runs out of time.
On my VPS which has same php version and memory settings (and mysql db) the ...
1
vote
1
answer
39
views
Index table not displayed on new element type
I am writing a data tables plugin and am currently working on the index page in the CP.
I've followed the instructions here:
index.twig
{% extends '_layouts/elementindex' %}
{% set title = "...
1
vote
1
answer
28
views
Save metadata on entry without creating a corresponding field
I am trying to add a seeded:true flag to dummy entries seeded during development, so I can automatically weed (delete) them later when I'm ready to save the actual live content.
I know I can create a ...
1
vote
1
answer
96
views
How can I see what fields changed on EVENT_BOEFORE_SAVE and or EVENT_AFTER_SAVE
I want to see what data is changing whenever someone is updating an element to act on the difference between the states. In this particular case a User, but more abstractly speaking, an element.
In ...
1
vote
1
answer
134
views
upload base64 image -> save in assets -> custom plugin
I started coding a custom plugin, it takes a video file from the asset and showing the file in a video-player (CP). The user is now able to take screenshots of the video (using JS) by clicking a ...
1
vote
1
answer
81
views
Upload asset via API - Asset saved under root folder
I am trying to seed some images to an existing volume programmatically.
The code I'm using is taken (almost) verbatim from Craft's AssetsController@actionUpload:
$filename = Assets::...
1
vote
1
answer
80
views
Check for existing jobs in queue
Is it possible in code to search for a job/list out all jobs?
I have built a plugin that scans an external API and I want to scan on an interval as well as allow the user to fire off a manual scan. I ...
1
vote
1
answer
43
views
Install plugin from another plugin
I'm trying to use Redactor as a dependency for a plugin I'm writing.
I need it to be installed before I run my Install.php migration, because in the migration I'm creating a Redactor field.
Following ...
0
votes
0
answers
53
views
getDirtyFields returning more results than expected
I have a module that sends an email whenever a specific entry field is updated. Everything is working fine except that the field is being passed to the dirtyFields array even if it has not been ...
0
votes
0
answers
40
views
Send email from two different addresses using SMTP
I have a configured and fully working Craft 2 website that sends emails using the SMTP settings I have set in the admin panel.
I am in need to send a specific email in a certain situation from a ...
1
vote
1
answer
19
views
Composer Unexpected end of file on new plugin
I'm making a new Plugin for CraftCMS, it works fine locally but when I call the services class on our staging server it throws a Syntax Error, Unexpected end of file.
I've installed them both through ...
1
vote
1
answer
47
views
Manipulating search event
Looking at a means to perform subqueries against certain searches in the back-end of the Craft CMS eg for searches against particular sections within Admin > Entries.
Looking into this it seems ...
1
vote
1
answer
31
views
Limit elementSelectField to specific sections
How do I limit this elementSelectField to only allow entries within a certain section?
{{ forms.elementSelectField({
label: 'Blog post',
name: 'blogpost',
elementType: 'craft\\elements\\Entry',
...
1
vote
1
answer
62
views
How do I renew Craft CMS license?
When I go to Updates in my home Dashboard, I see there are "5 updates available!" I click "Go to Updates" and a big orange ribbon pops up that reads: Your license has expired! ...
0
votes
1
answer
34
views
All Plugins Showing "Not Installed" After Promoting Changes From Dev to Stage Environments
We are using the custom exec widget to move the codebase, backend fields, section creations, and images from one environment to another.
We have Dev, Stage, and Production environments. After ...
0
votes
0
answers
36
views
How can we create the Martix type field?
In Plugin development, I have created a field, Is it possible to create a field as a matrix field or I will have to create custom add more functionality?
1
vote
1
answer
147
views
Posting data from CP to Plugin controller results in server error 500
I am currently trying to write my 1st Craft plugin.
The goal (simplified):
Backend users select a bunch of pages in the CP, and create a PDF. The result is an annual report that's optimized for print (...
1
vote
1
answer
88
views
How to display controller response on twig template?
In the plugin, I created a form and after the process, return the below response from the controller and redirect to the template. I am trying to print the response to the template but it's not ...
1
vote
1
answer
48
views
Create a channel programmatically
I am diving into Craft plugin development and there is one thing that I want to achieve, but I didn't find any documentation.
I managed to save specific new entries into a channel using saveElement(), ...
0
votes
0
answers
127
views
Guzzle fatal error using Craft Guzzle client
Using the code below to get 3rd party API
$uri = $baseUri . '/area/' . $areaId . '.geojson?api_key=' . $mapAPIkey;
$client = Craft::createGuzzleClient();
$response= $client->request('...
1
vote
2
answers
82
views
Running a background job in a controller
I am trying to run a background job in a controller but wondering if its actually possible. I'm not sure about namespacing and could do with some guidance on whether the job should be running in the ...
0
votes
0
answers
13
views
Running a a join query in a plugin with a background job API call
I'm working on a plugin and need some steering. I have two sets of entries that are linked by a foreign key value. (They are not related entries but lsoaname value corresponds to a field in 2nd set of ...
1
vote
1
answer
59
views
Can some one explain Event rules in plugins
So here is what I see in a controller:
$event->rules['cpActionTrigger1'] = 'plugin/default/do-something';
What does the first part 'cpActionTrigger1' refer to and what does the second part refer ...
1
vote
1
answer
116
views
Why do i get an Invalid route error in cp when calling plugin action?
I have a plugin that has a menu and in backend which basically has a button that calls the plugins default controller actionXXXX method.
The action does some database / api work then is meant to ...
0
votes
0
answers
13
views
Include File In Multiple Plug-Ins
In Craft 2, I would like to share the same include file among several different plug-ins.
Is this possible, and, if so, where in the directory structure would that include file go?
Thanks