Questions tagged [plugin-development]

Questions having to do with constructing plugins.

Filter by
Sorted by
Tagged with
0
votes
0answers
12 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
24 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
27 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
23 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
29 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
26 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
23 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
22 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
22 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
22 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
33 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
16 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
38 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
25 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
24 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
32 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
27 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
26 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
26 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
78 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
46 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
19 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
48 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
23 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
17 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
60 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
vote
1answer
45 views

How to overwrite base controller beforeAction method

How do you override the beforeAction method of Craft's base controller? I'm disabling CSRF for a specific route. public function beforeAction($action): bool { $requestOrigin = \Craft::$app->...
1
vote
1answer
20 views

Assign a category group to a category field via migration

I am writing a plugin that sets up Craft in a particular way and have created a category field, but can't figure out how to assign a category group to the field, I have the following: protected ...
0
votes
0answers
16 views

Is there a way to add a column to entries without making a field?

I would like to add a setting to password protect certain entries if the user chooses. I don't want to create a custom field, but rather have this on the sidebar that the user can toggle on and off ...
1
vote
1answer
30 views

Get all elements (entries) where a field exists

I'm developing a plugin and I'm searching a way to get all entries where a field exists (by id or handle). I'm trying to get all the entries even if the value of the field is null, empty or text. I ...
0
votes
0answers
26 views

Load Entries after click (AJAX)

I try to load a entry after a button is clicked, currently my code looks like this: This is generating a 404 error. Dunno why? <?php /** * PopUp plugin for Craft CMS 3.x * * test * * @link ...
1
vote
1answer
28 views

How to work getFieldValue for assets

I have been implementing my own PHP plugin code. In that, I need to get an asset field in user info. If I can get if the asset is set on the field or not, it is enough. I can get the values of text ...
0
votes
0answers
27 views

Passing variables to email template not working

I am building a Craft plugin which sends emails to users of a subscribed list. I'm trying to get Craft to send the email with a Twig template and pass in variables to that template. So far I've been ...
1
vote
1answer
29 views

Do something on save of an entry

if that entry is in a particular section, then I want to do some task. I can't really find the event docs I need to do that. Everything I've come across has been for Craft 2. Any steps for a hint?
0
votes
0answers
8 views

How Might A HUD Editor Be Extended For A Third Party Field Type?

How might one go about extending a field layout in the Craft CMS control panel HUD editor? Specifically, a Solspace Freeform Submissions field type. Please see attached. We'd like to quick-edit ...
0
votes
0answers
27 views

How can I get uploaded images from my controller and upload them to Craft?

I'm using dropzone to upload images on my front-end. The form action url is to my controller from a custom plugin and that works fine. However, now I'm trying to get the files from dropzone (a json ...
1
vote
1answer
43 views

CSRF in plugin dashboard widget 400 error

Yes, it's another csrf question, the standard, 400 Error - Bad Request: Unable to verify your data submission. If in config/general.php I set 'enableCsrfProtection' => false, then everything works ...
1
vote
2answers
75 views

Parse variables into twig email template from custom module

I'm trying to send an email from my module and am trying to pass some vars into my module template that I can render using twig. Please note that this is a module template not a front end template. $...
1
vote
3answers
52 views

How to create a new Entry model in Craft 3?

I want to create a new entry for a section named 'drinks'(having section id= 6). The namespace of the file having this code is namespace putyourlightson\userguide\controllers;.I copied this code from ...
0
votes
0answers
30 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
35 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
15 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
20 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
42 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 %} ...
1
vote
0answers
18 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
40 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
30 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
89 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....

1
2 3 4 5
33