Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [plugin-development]

Questions having to do with constructing plugins.

0
votes
0answers
11 views

Update field setting value using getFieldByHandle

I need to update the limit setting for Images allowed to be empty, so as to allow for no limit. How do I go about updating the 'limit' setting? $fieldsService = Craft::$app->getFields(); $field = $...
0
votes
0answers
20 views

How to exclude some fields from the searchindex using the RegisterElementSearchableAttributesEvent event?

Context I had big issues on a Craft 2 multilingual site with dozens of thousands of entries that were using Matrix fields. The site had become extremely slow (almost unusable), especially when ...
1
vote
1answer
20 views

where command sql query not working

My problem is that I can't update the specific $userId. have the values I've selected. I also get an error: Call to a member function where() on integer I just started to learn Craft. It can be ...
1
vote
1answer
23 views

Reducing memory usage?

I have a relatively simple task which is exposing an issue with efficiency. In that it isn't very efficient and the server cries and quits. Here's the high level overview: There's a category called "...
1
vote
1answer
16 views

Craft 3 validate new password in change password

I'm trying to validate user's new password and confirm password in my custom plugin init(). Event::on(User::class, User::EVENT_BEFORE_SAVE, function(Event $event) { $formData = $_POST; $...
1
vote
1answer
19 views

Tasks runs only after admin is logged in

I have a plugin which runs a task on order complete. The tasks runs successfully without any errors. But the problem is the task is only completed when admin is logged in. So if someone has completed ...
1
vote
2answers
16 views

How to disable plugin Disable and Uninstall?

I am developing a site with a customer logged in area. I don't want anyone to access the section if they are logged out and instead redirect them to the login form. I could just add {% requireLogin %...
1
vote
0answers
18 views

Add custom column to the orders list page

Does anybody know if it is possible to add a column to the orders list page? I can choose the 'Foo' label, but when the page want to show the orders list I get the following error: "{"error":"An ...
1
vote
2answers
18 views

Sending Error Message to Template With No Logged In User - Craft 2

I'm working at getting error messages sent from my plugin to my template (on the front end), when there is no session (no logged in user). The plugin is for LDAP authentication. Edit: For ...
1
vote
0answers
8 views

Excluding entries based on a tag across whole site

I'm trying to exclude entries that are tagged "DO NOT PROMOTE" on any page where craft.entries is used minus their actual entry page. What I've come up with so far is this: public function init() { ...
2
votes
0answers
23 views

Commerce 2 Multi-site Support

I'm currently working on a multi-market Craft3 project with Commerce2. Each product can and will have a different fixed price on each page. Product A project.tld/de-de - € 120 project.tld/en-gb - £ ...
1
vote
1answer
18 views

Do field values get serialized before validation?

I am learning to write my first plugin for Craft CMS 3.x I have a field that gets displayed as a string, but is stored in the database as binary. When I validate it, I write: public function ...
1
vote
1answer
22 views

Allow users to edit user account email from front end form in Craft 3?

Is there a way to allow users to edit their email address via a front-end form in Craft 3? My understanding is this would require an 'elevated' user session. Which I'm guessing can only be achieved ...
0
votes
1answer
34 views

Programmatically Log In From Plugin

I'm writing an LDAP authentication plugin, which, if the authentication matches, will log the user into a 'general' username/password, in order to view a protected page. The 'general' username/...
0
votes
0answers
21 views

Element API - combine results to one or more arrays

Im currently creating a calendar for sorting and selecting "movies". Movies have a title, images, shows etc. And for each "show" there is an matrix block with a link to tickets, date, time, ...
0
votes
1answer
8 views

Does Craft ActiveRecord require any special table column (dateUpdated, dateCreated,…)?

I have a custom data table PA in the Craft database. I create a craft\db\ActiveRecord model and I want load() and save() data to it. The result will be custom GridView table with CRUD in front end ...
0
votes
0answers
24 views

Custom plugin: asset fieldtype

I have a custom plugin that uses a custom field leveraging the elementSelect fieldtype to select an asset (which is then processed on submission via a custom service). However, when I select an asset ...
0
votes
1answer
15 views

Trigger download after form submission

I am working with a contact form plugin, written by an external developer several years ago. I want to trigger a file download upon successful completion of the form. As it stands, I have an onPost ...
0
votes
2answers
48 views

Craft 3 Plugins - Setting Template Path To Site Templates

In Craft 2, if you have a plugin that needs to load a view from the site templates directory, you could just go: # Set the template context to site templates. $path = craft()->path->...
0
votes
1answer
20 views

Updating craft user fields from plugin

I have 2 forms on my site, one that registers for the WHOLE site and one that registers for just the downloads on the site. I wrote this custom function to change the user group if the email existed. ...
1
vote
2answers
30 views

How to Access the Twig Attribute Name from the Fieldtype Class

I want to be able to output different values for my fieldtype depending on the twig attribute. So {{ entry.myField }} would output AK by default, but {{ entry.myField.label }} would output Alaska. ...
1
vote
1answer
17 views

Custom Field Settings: Unknown Property Error

I have a custom field with a setting for regionType, but when I try to save the field I get this error: Setting unknown property: kgrote\siteutilities\fields\Regionselect::regionType In my ...
0
votes
0answers
7 views

Type number form in textField for plugin

I haven't found any fields that deal with numbers for a plugin. I've changed a forms.textField into a type:number which has seemed to work fine for the most part. But I can't find a way to keep ...
0
votes
1answer
21 views

Custom Plugin Field Using Wrong Template Path

I'm trying to build a simple dropdown field with a pre-populated set of options, so I figured I'd just import most of the methods from Craft's native Dropdown field. The plugin name is siteutilities ...
1
vote
1answer
22 views

How to use the default HTML email template when sending an email from a plugin?

On /admin/settings/email, when the HTML Email Template field is set to a valid template, all system messages are sent using it. They inject the content of the messages inside the {% block main %}{{...
1
vote
0answers
23 views

Recommendations on integrating Craft 3 and FormAssembly

I was wondering if anyone could give me some advice. We have a client that we are in the process of moving away from a Drupal build to a new Craft build, however, they have a large number of forms ...
1
vote
1answer
8 views

What's the differences between the Mailer and the Message classes?

In the Craft 3 Class Reference (https://docs.craftcms.com/api/v3), there are two classes under craft\mail: Mailer Message I found that I was able to send an email using this: <?php use craft\...
1
vote
1answer
49 views

Craft 3 How to get custom user field values

I have following custom fields for users. favouriteEntries - 'entry' type field with multiple entries per user notificationPreference - Lightswitch field My plugin should email notifications to ...
1
vote
1answer
15 views

Is there any way to replace the asset programatically?

In the CP, when we upload an image with a same name, craft will ask if we wanna keep both or replace. So in plugin, is there any way to do the replace?
2
votes
1answer
56 views

Separate User Groups / forms

I have two forms on my site, one that you can use to sign up as a registered user that allows you to view content through out the site and participate in steps (tests) etc. The second form is a form ...
1
vote
1answer
31 views

Plugin development: how can I check if user has the permissions to delete only his own assets?

I have a front-end form where logged users can upload and delete their personal files. These users have the strict minimum permissions required to interact with this form. They can only Create, ...
0
votes
1answer
17 views

How to get one entry's related stuff in Vuejs component

For example, in a vuejs component, i send a ajax request to get an article. And in this article, there is a relation field called relatedTopics. How can I get this article's relatedTopics with ...
0
votes
0answers
33 views

How to upload an image to an entry?

In front-end, I have a file input field with the name headerImage. <input type="file" class="form-control" name="profileImage" accept="image/*"> At the back-end, I do something like this: $...
1
vote
1answer
30 views

How to recreate symlinks to path-based plugins after moving to live server?

I have a couple of custom plugins for a site, which I successfully added by using path repositories in my composer.json file. However, when I upload the site to my staging server (via FTP - no SSH ...
0
votes
0answers
18 views

Using Rich Text in own plugin templates (CP)

I'm developing a custom plugin with its own CP templates. I'm, extending the CP layout fine and importing the field macros built into Craft just fine, eg {% extends 'enquiries/layout/_cp' %} {% ...
1
vote
1answer
30 views

How to fetch entries in custom plugin Craft 3?

I am creating custom search based on entries. I need to fetch entries in custom plugin.
0
votes
0answers
22 views

How do I access current site handle in Craft3 controllers

When my multisite is set up as @web/site, I cannot access the current site handle from my controllers. Craft::$app->getSites()->currentSite->handle I think this is because my form action ...
1
vote
1answer
23 views

In Craft 3 plugins, should CRUD operations go in Controllers or Services?

The documentation states: Many service methods perform some sort of operation for a given model, such as a CRUD operation. (Link) But browsing through existing plugins, I see the CRUD logic is ...
2
votes
1answer
34 views

How to query entries by field values

I have some entries with a multi-select field called "gallery". We can choose many images to this field. I have a given image, how can I query entries whose "gallery" contains this given image? Thx! ...
1
vote
1answer
84 views

What's the difference between a Component and a Model in Craft 3?

I'm trying to familiarize myself with the Craft architecture and I can't understand whether I should be extending craft\base\Component or craft\base\Model for my business logic models. Component seems ...
1
vote
1answer
12 views

How do I disable the default translation feature for a custom field?

I am making a custom field that provides granular control of what values will be translated and what values will remain shared across multiple sites. Because of that, I'd prefer to entirely the ...
1
vote
2answers
39 views

Unable to edit my Craft 3 Plugin

I've managed to create a simple plugin for craft and get it into my project. It shows up just fine but I can't make any edits. I've tried editing the original plugin files and updating via composer ...
1
vote
1answer
42 views

How to validate a unique field in Craft 3 element?

I'm trying to validate a custom Element in my Craft 3 plugin. Where should I be putting my validation rules? I have two classes: one for the Element, one for the ActiveRecord (e.g. Invoice and ...
1
vote
1answer
14 views

Special characters in `template->renderObjectTemplate` method

Having a problem with the Formerly plugin where it is throwing an error if CSS is passed into the Submission body. Not sure if this is a Craft of a Formerly problem but looking into it further, the ...
1
vote
1answer
33 views

UnexpectedValueException after loading plugin

I'm attempting my first Craft plugin and trying to update https://github.com/matthewattanasio/Craft-Url-Decoder-Twig-Extension for Craft 3 and followed the instructions in the docs for loading plugins ...
2
votes
1answer
31 views

Craft Commerce 2 - get order data for plugin

I want to write a plugin which writes all the order data into a CSV file. Unfortunately the documentation for Commerce 2 isn't quite complete yet so I have difficulties to find out how to do the ...
2
votes
2answers
98 views

Plugin I created is asking for a license key

I created a plugin for a client website and I keep getting license issues popping up in the admin panel for it. Not sure what I am doing wrong here. Obviously I have no intention of putting it into ...
1
vote
1answer
26 views

Plugin stops working when logged out

I have a plugin that sets the user group based on whether a hidden checkbox has been ticked on the sign up form. The plugin works exactly as I want it to while I'm logged in, but as soon as I log out ...
2
votes
1answer
17 views

Plugin, getting an entry when one of multiple category fields and/or lightswitches are not empty/turned on

Basically I’m trying to get en Entry where, either one (or more) of three lightswitches is (are) turned on, or where either categoryOne or categoryTwo is not empty. This is what I got so far, but it ...
1
vote
1answer
34 views

How can I call console controllers

I have a controller in the console folder. How can I call this controller via ajax please? I tried to config a route in Routes.php, and then call this route by jquery Get() function. But none of ...