Questions tagged [plugin-development]

Questions having to do with constructing plugins.

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

Plugin Settings Color Input Javascript Event Listeners

Is it possible to attach JavaScript event listeners to the colour input field in a plugin's settings page, so that when a user selects a colour with the picker I can run an AJAX request?
1
vote
1answer
30 views

Getting unknown property: craft\feedme\events\FieldEvent::fieldValue

Getting a strange error when trying to check if a field is null when importing via FeedMe Getting unknown property: craft\feedme\events\FieldEvent::fieldValue use yii\base\Event; use craft\feedme\...
0
votes
0answers
12 views

Craft Commerce: Wrong payment currencies in orders

I have Craft Commerce installed on my site (which uses Craft CMS 3.5.14). I have set up multiple payment currencies for it (NZD - which is the base currency, AUD, EUR, GBP, JPY, USD). When I go to ...
2
votes
2answers
63 views

Feedme Skip Entry if No Matching Elements on Field

Is there a way on Feedme to not import an entry if it doesn't have a match on a specific field? e.g. If there is no entry that it matches up to, don't import it. Here's the current code I have: ...
1
vote
1answer
32 views

Can I apply adjustments (discounts) through a controller?

I have a controller which when called (actions/some-module/discount-link/apply?code=abc) associates abc with an entry and based on some stuff in that entry populates the cart with some specific ...
1
vote
1answer
38 views

FeedMe Change Slug when Importing

I asked this question previously before Feedme was acquired by Craft, though I haven't updated Feedme & the code since now. I'm getting the following error when processing my feeds. I'm trying to ...
0
votes
0answers
6 views

Add input fields to plugin settings with JS

I'm working on a plugin and I want to be able to add fields to the plugin settings page when JavaScript event listeners are fired. My first idea was to output an input field using Twig, and then ...
1
vote
1answer
14 views

Running plugin migrations when other plugin is installed?

I'm creating a plugin (A) that has optional support for another 3rd party plugin (B). When my plugin A is installed, I create a number of tables. If plugin B is also installed my migrations create ...
1
vote
1answer
21 views

Partially pay for an order

Is there any way of partially paying for an order, so if the order total amount was $100, how can I programmatically set the payment amount to $50, and then pay the other $50 using another payment ...
0
votes
1answer
35 views

$this->renderTemplate() breaks the CP navigation

I'm locally working on a Craft Plugin with a Page in the Control Panel where I have a form that posts to a controller. <form action="/actions/import-products/product/create" method="...
1
vote
1answer
15 views

dev- branch plugin forks being prompted for update

I'm currently using a fork of a plugin for my site, and using a "dev-[branch-name]" version specification in the composer "require" block, with a "vcs" repository ...
1
vote
1answer
20 views

Hide/show element actions dependent on tab

I have a custom element index with an element action to 'Approve' elements. The element index has 'Live' and 'Staged' sources. Where/how do I set it to only show this action on the 'staged' source OR ...
1
vote
1answer
28 views

Updating plugin/module config via template/controller

I have a plugin/module that synchronises local records with a Google Sheet managed by the client. The URL for this doc is stored in a module config. I want the client to be able to update this via the ...
1
vote
1answer
49 views

Element type with 'baked-in' fields

I've created an element type and want to have a 'Categories' and 'Tags' field built-in (the sources for each will be selectable in settings), but can't figure out the best way to go about this whilst ...
0
votes
1answer
32 views

Schedule plugin not working for Feed Me plugin

I have created a schedule to run the 'Feed Me' every 1 minute using the plugin 'Schedule', but it doesn't work. I not sure am I using the correct setting or not. I manage to get the latest data if I ...
1
vote
1answer
33 views

Creating a calendar event from within a plugin (stuck on saving)

I'm trying to create an event from within a plugin. I've come up with the following: $event = new Event(); // Solspace\Calendar\Elements\Event; $event->authorId = 1; $event->calendarId = 5; $...
1
vote
1answer
39 views

Eager load commerce order data in custom ElementExporter for Users

I have a custom ElementExporter for users and I'd like to include commerce order data. The below code works, but it's a ton of queries. I don't have a ton of experience with SQL queries, how can this ...
0
votes
0answers
26 views

Saving custom element types

i have created my first plugin and have hit a bit of a wall... its a plugin with a custom element type, i have it creating its own database table (migrations/install.php) and i have the form ...
1
vote
1answer
15 views

Archiving custom element types

I am building a custom element type and want to have the ability to archive entries. I can create a custom status for 'archived' but I've noticed base elements already have an 'archived' status I ...
1
vote
1answer
14 views

returning HTML in $event->sender->addErrors doesn't work

I have a plugin which is checking if there is a duplicate entry before save. I'm trying to give the user back an anchor to the entry which exists so my client can switch without searching for it in a ...
0
votes
0answers
12 views

Custom Plugin forms.textareaField Redactor buttons not rendering

I am struggling with how to get Redactor to show the source and image buttons within a custom plugin. Are there only certain buttons that are allowed if you are extending textareaField? Below is the ...
2
votes
1answer
25 views

Programatically setting dropdown options in a matrix

I'm building a Matrix field from within a module's migration. I can get all fields setup correctly except the options of either a Dropdown or Checkboxes field. $field = new \craft\fields\Matrix([ '...
0
votes
0answers
15 views

How to override filename saved in Sprout Forms?

After a form is saved I need to concatenate together the {{proposalCompanyName}} handle with the {{proposalFileUpload}} handle so that the saved filename in the Assets folder is proposalCompanyName....
0
votes
1answer
40 views

Rendering a template from a controller - unable to find template

Once again going out of my mind trying to figure something out... I have a custom controller which I want to return a rendered template. The template should, ideally, reside in my front end templates ...
2
votes
1answer
33 views

unsucessful setFieldValues after programatically creating field on a migration

as part of a migration script I'm trying to: create 2 new fields, add them to a field group add the new fields to a specific tab on an entry type Update the values of the new fields What I have so ...
2
votes
1answer
26 views

Licence error and update issue cause of same plugin name / handle

We developed a plugin with the name "poll" (composer.json: webhub/poll) for one single project. Now we get the licence error in the control panel, cause there is a plugin to buy which has ...
0
votes
0answers
36 views

Plugin: Record relationship with Entry

I'm trying to build a plugin that has relations with Craft entries. The plugin db table has field called entryId that defines a foreign key to the {{%elements}} table. Then my Record class extends ...
1
vote
2answers
30 views

What is the best way to handle HTTP requests within a plugin using Yii or Craft?

I have a custom module which is moderating content before entry save, I am looking to use a Microsoft Azure API to handle the moderation, in their documentation they use a HTTP library to make the ...
0
votes
0answers
24 views

Saving to db with devMode true works, but not when false

// Upload and save as temp file $request = Craft::$app->request; $file = UploadedFile::getInstanceByName('file'); $tempPath = $file->saveAsTempFile(); // Create as permanent asset $folder = ...
0
votes
0answers
23 views

Timezone in Craft different from timezone in plugin

In general.php I've set 'timezone' => 'Europe/Oslo'. When saving entries through the CP they are saved with the correct time. Also, date_default_timezone_get() from my plugin returns Europe/Oslo. ...
1
vote
1answer
24 views

Craft 2: possible to control plugin triggering order?

I have a Craft site which has 2 different plugins listening to the same event (the Contact Form beforeSend event). The outcome is one is being triggered before the other and this is causing issues. Is ...
1
vote
1answer
34 views

Tax validation in Craft Commerce

We have a single page checkout where the items are selected and addressed added before going to a cart summary page showing amount owed and tax due. Was confused as to why certain codes were not ...
1
vote
1answer
37 views

Looking to create a dropdown field to select an icon

I use the same icons across most of my projects, and typically just list them in Dropdown fields. However, this quickly becomes difficult to manage, so I'm looking to create a simple plugin that I can ...
0
votes
0answers
26 views

Programmatically / with plugin create new categories and nested categories

In a custom plugin, I'm able to easily add a new Category: Parent Category Code: if ($category[1] != '' && $category[1] != -1 && $category[1] != 0) { $categoriesData = \...
1
vote
1answer
20 views

Craftnet API package query

Does querying composer packages via the Craftnet API need authentication? Ref https://docs.api.craftcms.com/packages.html Querying the Craft CMS package itself is fine, eg https://api.craftcms.com/v1/...
0
votes
0answers
52 views

Modifying a GraphQL element query using a custom field

There’s an address field plugin that doesn't yet support GraphQL, but I'd like to re-create something that I could do using Twig in GraphQL based on this plugin’s custom field. In Twig you would do ...
2
votes
1answer
33 views

Dynamic postCpLoginRedirect based on user permissions

I'm wondering if it's possible to set the postCpLoginRedirect config setting dynamically during plugin initialization. Seems like that's a no-go, but wanted to confirm. Ideally, I'd like to ID users ...
1
vote
1answer
29 views

How to auto enable a plugin after install?

I am developing a plugin for craft 3 and the plugin just got published to the store. I can browse through the store and install the plugin but it stays disabled. The user will have to goto Settings -&...
1
vote
1answer
58 views

Equivalent of Records in Craft 3?

Trying to convert a plugin from Craft 2 to Craft 3, not sure what's the Records equivalent in Craft 3. How do I get this to work in C3? class SearchRelationshipRecord extends BaseRecord { public ...
1
vote
1answer
33 views

How to get my craft projectConfig settings inside JS on the front end

So I am trying to work with twig templates and I want to inject my project configuration in my js so I can use it. I can do this {% set admin_email = craft.app.projectConfig.get.email.fromEmail %} ...
1
vote
1answer
67 views

Register custom REST routes while building a plugin for Craft 3

I am building a custom plugin for Craft and I am hitting some REST APIs in my backend service to fetch some data using Ajax calls in JS. What I would like to do when the AJAX calls complete and come ...
1
vote
1answer
32 views

How to reset matrix field to have NO blocks in plugin?

I want to reset a matrix field to have no blocks in it. In a plugin, I would normally set a matrix field by doing something like this: $blocks = []; $i = 1; foreach ($itemsArray as $item) { $...
0
votes
0answers
26 views

Are plugins necessary for these 2 things?

I'm working on migrating an existing project, that is currently made in CodeIgniter and I'm trying to port it to Craft. Everything is great except... I'm running into two issues: Have a page ...
1
vote
2answers
99 views

Commerce: Remove tax adjuster from line item in plugin

I need to remove adjusters from each line item if a certain condition is not met. I see that in the CP you can manually remove them by editing the line item but hunting down this code in Commerce's ...
1
vote
3answers
49 views

How to add content to pages using a plugin?

I am developing a plugin for Craft 3. And I am trying to add some content to all pages in the CMS using this plugin. How can I do that? Is there a method or class call I can use for this? I am not ...
1
vote
1answer
27 views

Images not showing even after bundling them with asset bundle

So I am trying to build a simple plugin for Craft CMS and I am wish to use my assets in the twig template like css, js, images etc. From what I have read and understood from Asset Bundles, I have ...
1
vote
2answers
62 views

How to show flash message for Commerce order when changing status on listing page?

If I change an order's status to "Cancelled" (my custom order status I created), I want to ensure that the CP editors provide a "Cancellation Reason" from a dropdown field in the order. I've set up a ...
1
vote
1answer
25 views

How to use assets while building Craft CMS plugins?

I am trying to build a basic plugin, when installed has a single nav bar item, and of course a twig template which shows up on clicking on that navbar item. I have used the basic template to extend ...
1
vote
1answer
19 views

Craft plugin or external application

My question is more conceptual than technical; I have a website who have two big topics, on is purely editorial (pages, articles, faq, ...), the other is basically a comparator based on user input ...
1
vote
1answer
75 views

how to create Super Table field programmatically

i am trying to create a super table field programmatically. this is the code i tried. i see super table field in field list but i can see fields inside of super table. how can i do this? //...

1
2 3 4 5
34