Questions tagged [modules]

Questions related to Craft 3 Yii Module Development

Filter by
Sorted by
Tagged with
1
vote
2answers
21 views

Get System Activation email link

On my site a type of user can add new clients and I wanted to automate the activation email, so that when a new user is added then the client will get the activation email. But I'm getting an error ...
1
vote
1answer
30 views

Craftcms 3 Module - API call validation (on EVENT_BEFORE_SAVE, EVENT_BEFORE_VALIDATE, EVENT_AFTER_VALIDATE, EVENT_AFTER_SAVE)

I am trying to validate entries on Save in a Module. My specific use case requires that the Entry validation - on failure to validate will return user to form with field errors. On successful ...
3
votes
2answers
47 views

Check if a FieldHandle exists in Module without throwing 'Invalid field handle' exceptions

I've been pulling my hair out trying to work this one out. I'm building a module to auto-populate a super-table on EVENT_BEFORE_SAVE, the module works exactly the way I want it to, everything seems to ...
1
vote
1answer
21 views

Class '…SiteModuleService' not found when used inside scout.php

I have a custom SiteModule that is used inside scout.php to deliver indexing data to Algolia. I have followed CraftQuest's tutorial on creating a custom SiteModule for handling the indicies. The setup ...
0
votes
1answer
22 views

Add a form field into the details bar on the entry edit screen and do something with the value

I'd like to add a form field into the details bar on the entry edit page, so that when the entry gets submitted, the form field value gets passed into the data payload so that I can pick it up from ...
1
vote
1answer
28 views

How to remove category link from redactor links but leave assets and entry link

This is a follow up from How to remove Link To Category from Redactor. I've been able to setup the module and remove all links with this: Event::on( RedactorField::class, RedactorField::...
1
vote
3answers
75 views

What is the correct way to format a module controller action URL?

Consider the following Craft 3 example module structure: modules/ businesslogic/ controllers/ExampleController.php BusinessLogic.php ...and consider the following action in ...
0
votes
0answers
30 views

How to convert custom plugins to custom modules

I have 3 custom plugins that we had someone develop for us a while ago and I would like to convert them to custom modules. Since plugins are based upon modules, I was hoping there might be a cookbook ...
1
vote
1answer
53 views

getDirtyAttributes() not showing changes

I've got an event listener in a custom plugin where I want to check to see if the users email updated, but it doesnt show that attribute as dirty, even though I know it should be: Event::on(User::...
0
votes
0answers
40 views

Request didn’t meet the user agent and IP requirement for maintaining a user session when website posts to our action URL

We have a module that has an action controller method that a third party website posts data to. We can see that often, we can't save the data and there is an error "Request didn’t meet the user ...
1
vote
1answer
21 views

Removing the Save button based on some condition

I want to remove the Create button of an entry based on some condition (review states) for some users. Is there a way to hook in within a module?
2
votes
1answer
107 views

Failed to instantiate component or class error

I have a site with a custom module that was working fine until just recently but I tried to do a plugin update via CLI and it returned Failed to instantiate component or class "modules\exifreturn\...
1
vote
1answer
21 views

Craft commerce 3 - Module - Lineitem - Get usergroup

I have the following code working. The only thing i have to do is to check which usergroup is the customer in. Is there a simple way to check what usergroup is the customer in? This is my first custom ...
1
vote
1answer
149 views

Custom Module: new element type index page access

Hello I've created a new element type in a module (a web app within Craft) that I'm developing. I have initially created my models to be craft\db\ActiveRecord and save directly to their tables, but ...
1
vote
1answer
152 views

How do I get the siteName in a module (Craft 3)

In templates I can do something like {{siteName}}. But how do I retrieve this in a module? I've tried: Craft::$app->config->siteName I can grab my custom globals via Craft::$app->globals, but ...
1
vote
1answer
33 views

After signup action

I'm trying to add an action after user signup so that we can post the clients external system so we can retrieve a customer number that we require. My question is does EVENT_BEFORE_VERIFY_EMAIL run as ...
4
votes
1answer
113 views

Is there a way to compare what has changed on an entry while it's being saved?

I'm taking my first baby steps into the php side of Craft, and my php experience in general is extremely fledgling. But I'm pretty much forced to create a module for a project I have, so here I am ...
2
votes
1answer
33 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
17 views

Problem with entry relations in using craft + postgres

I have a custom module saving entries into the system and those entries contains several category relationships. I have done the same previously with MySql and never had problems. I am currently ...
1
vote
1answer
166 views

Change matrixblock field value before save element

So i have a Matrix with one type of matrixblocks. These all have a field for a custom id which should be set by the system, if empty, before the entry is saved. I can access the individual ...
0
votes
0answers
15 views

Event or hook to access when needing to show session messages via AJAX within Asset Events in the control panel

I am using EVENT_BEFORE_HANDLE_FILE on the asset class to moderate images before they are uploaded. I am setting session errors which show fine on the frontend templates on page refresh, however in ...
1
vote
1answer
16 views

Stop image upload if moderation fails using EVENT_BEFORE_HANDLE_FILE

I have a frontend form where images can be uploaded. I am handling the image moderation within EVENT_BEFORE_HANDLE_FILE on the Asset class. I am setting session errors for any moderation issues ...
0
votes
0answers
21 views

Fail validation of frontend form if field value is not unique

I was surprised to see that there is no plugin in the store for the purpose of requiring unique values on fields. I need to create a form that will not let front end users create an account if they ...
3
votes
1answer
32 views

Use own/custom field inside Craft Table

I made my own, fairly simple field inside a Module for Craft 3.x. What settings do i need to define to make it usable inside a table?
1
vote
1answer
40 views

Update entry title for all sites

I'm working on a Craft project that has 3 sites. The content for one section is pulled from an API using a console script which runs every 5 minutes. This has been working fine but I've discovered a ...
1
vote
1answer
90 views

EVENT_BEFORE_SAVE event not getting $entry-id when creating an entry

I don't know if it was with Craft 3.5, but did something change slightly when using the EVENT_BEFORE_SAVE event? I have a simple use case where I am encoding the entry ID and updating the slug when ...
1
vote
1answer
46 views

Module's control panel sub-navigation is not working properly

I have a problem with setting up a CP navigation for my module. In module's init() I declared the following: Event::on( Cp::class, Cp::EVENT_REGISTER_CP_NAV_ITEMS, function (...
0
votes
1answer
153 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 ...
1
vote
0answers
20 views

Show parents of entry in custom entries field extending BaseRelationField

The default BaseRelationField shows only the name of the selected entry in the field (e.g. "SubEntryX"). I created a custom entries field by extending the BaseRelationField in a module. Now ...
1
vote
2answers
247 views

Can you call a controller method from within a plugin/module in Craft 3?

I initially asked a question here about how to use Solspace Freeform to build a custom front-end login form. I gave up too easily and accepted the "it's possible but probably not a good idea"...
1
vote
2answers
101 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
90 views

How how can I restrict/fail a login using a User::EVENT_BEFORE_AUTHENTICATE hook?

When a user attempts to login, I check a 3rd-party to make sure they should have access. If they shouldn't, I need to stop them logging in. I have this working, but I could only get it working by ...
1
vote
1answer
153 views

Create new tables with a custom module

Is it possible to create new tables in Craft when building custom modules or do you need to build a plugin for this? Modules don't have the special "install" migration. So how does table ...
1
vote
1answer
32 views

Accessing Commerce ‘Product Fields’ in events hooks

I've added an Entries field called linkedCourseEntry to a Product (Product Type > Product Fields tab). In the Product itself I've assigned an entry. I need to access linkedCourseEntry from one or ...
1
vote
1answer
32 views

Rating like Like/Dislike

Hello! I need a rating like Like/Dislike. That it would be possible to assign likes and sort posts by them. Are there any ready-made solutions?
1
vote
1answer
47 views

Feed Me logs access from the front-end

So I've created a web portal for a client so they could upload a file which triggers a Feed Me feed (on that file). I handle the upload and triggering of the feed with a custom Module. I trigger the ...
1
vote
1answer
138 views

Update entry Enabled value based on field value when saving

I am trying to update the value of the entry enabled field depending on a certain field value. I am listening to the EVENT_BEFORE_SAVE event and have it updating as such $entry->enabled = $status =...
1
vote
1answer
171 views

Trouble finding the correct path to template in custom module and getting the “Unable to find the template” error

I've created a custom module trying to implement new field types. I'm using How to create custom field type in Craft 3 and https://github.com/mmikkel/IncognitoField-Craft3 as reference on how to ...
1
vote
2answers
242 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. $...
0
votes
0answers
38 views

At what point is siteId set for orders?

I have an adjuster I am trying to get to work, but the order has to come from a specific site in order for the adjuster to be applied. The siteId is 2, but when I try to get the siteId from the Order ...
1
vote
1answer
40 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
47 views

Normalize then validate unique entry in a custom module field

I have a custom text field in a module that the user populate with an EAN number. The input is getting validate by a "match" validator and then is serialized before save to get ride of the various ...
1
vote
1answer
53 views

Sending an e-mail to current user in FeedMe hook

I have made a custom module that allows a user to upload a CSV and import it using a FeedMe feed. This all works fine, however I want to send an e-mail to the user when the import has completed. I ...
1
vote
1answer
306 views

PHP Core Warning – yii\base\ErrorException Module 'newrelic' already loaded craft 3

I upgraded Craft 2 to Craft 3.3. Sometimes I am getting an error in admin like below when saving entries or taking some URL. PHP Core Warning – yii\base\ErrorException Module 'newrelic' already ...
1
vote
1answer
39 views

How do I render pages with dynamic content from a json feed

I am building a module to show a job/vacancy-list and the detailpage of a job, the data is fetched from a remote json feed. Currently I have the following routes to a controller in my module return [...
1
vote
1answer
294 views

Use sidebar nav icons in modules and plugins

When adding a navigation item, there is the option to specify an icon, but it seems to have to be a path to an SVG. I can see that Craft has its own icon library, and it has an icon I want to use. I ...
0
votes
0answers
175 views

Save and log in a user from event callback

I'm trying to build a plugin wherein after a user is created via the normal means via a front end template, the user is immediately logged in. My module is watching for the after save event on ...
2
votes
0answers
133 views

Conditionally attach behaviors to craft\elements\Entry by section

I'm trying to conditionally attach behaviors based on an entries section. The following code works fine, but I'm trying to clarify one bit: To avoid a yii\base\InvalidConfigException on the CP ...
2
votes
2answers
221 views

Trigger FeedMe import from plugin

I'm importing Real Estate properties every 30 minutes into my website. I have a controller action that triggers this but the import is extremely slow and blocks the entire site. Right now I'm ...
3
votes
1answer
173 views

Restrict Sources on element select field

I'm building a module with a form that includes an element select field that I want to restrict to specific volume. So far this is what I have: {{ forms.elementSelectField({ label: "Asset"|t('app'...