Questions tagged [modules]

Questions related to Craft 3 Yii Module Development

Filter by
Sorted by
Tagged with
0
votes
0answers
11 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
33 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
21 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
21 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 ...
0
votes
0answers
13 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
22 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 ...
0
votes
0answers
28 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 ...
0
votes
0answers
22 views

404 error when trying to access a module controller action

I’m creating a module for a site for the first time and I’m having some trouble figuring out how to get the correct action url for my controller. I’m using this template for setting up the module: ...
1
vote
1answer
14 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
26 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 ...
0
votes
0answers
15 views

Edit/overwrite entries content dynamically using module

Is it possible to edit the content of entries from a specific section "on the fly" using module or plugin? I don't mean to edit database content, I mean to overwrite specific fields/properties during ...
1
vote
1answer
36 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
27 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
65 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
13 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 ...
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
12 views

When to bootstrap modules on every request?

Can someone help me understand the bootstrap array on config/app when loading modules? The docs state: If your module doesn’t need to get loaded on every request, you can remove its ID from the ...
1
vote
1answer
18 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
23 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
27 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 ...
0
votes
0answers
12 views

Distribute entries to a specific user group

I'm a complete module/plugin newbie and I'm trying to find a solution for this issue, but I really don't know where to start. I have a subscription model in which each month a bundle of digital goods ...
1
vote
1answer
82 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
33 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
99 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
42 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 ...
1
vote
0answers
69 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
112 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
93 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'...
0
votes
0answers
33 views

Craft 3 match all categories using relatedTo in a module controller

I am trying to perform an entry query using relatedTo to get entries that match all categories. I know how to achieve this with 'and' in twig but I can't seem to find the correct syntax to use in a ...
1
vote
1answer
113 views

Redirect to template from controller and pass data

I am building a custom login process which follow these steps: Request user email (submits to custom controller) Check if user has an account If they have an account, show a form requesting their ...
1
vote
1answer
71 views

Accessing named parameter in custom route from within a controller

I have a custom module in which I am setting a front end route that routes through to a controller. Like so: Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_SITE_URL_RULES, ...
1
vote
0answers
33 views

How can I override the Response status text from a controller?

I'm trying to set the statusText in a response, from a module controller. E.g.: <?php namespace modules\appmodule\controllers; use Craft; use craft\web\Response; class StatusController extends ...
1
vote
1answer
107 views

PS-4 Autloading custom module

I have created a module in modules/Core.php which works great and I can reference it using modules\Core::class. But I want to re-organise my modules. I'm not super familiar with PSR-4 loading but I ...
1
vote
1answer
78 views

How to set field values for the table field type in Craft 3

I'm trying to insert an entry along with values for a table field. According to the docs, the setFieldValues method takes an array of values in the format handle => value, but it doesn't specify ...
1
vote
0answers
58 views

Craft Commerce Adjuster API/PHP questions

I've got a module set up to add discounts based on criteria defined in a category group (handle 'productPacks') -> category (which is a "pack"). Now, everything works great for one type of pack, and ...
0
votes
0answers
43 views

Set field value of table field within matrix in a module?

I have a matrix called 'Election' with the structure: Block: role - Text field: roleName - Table field: candidates -- Text field: fullName -- Number field: votes My module can edit the roleName ...
3
votes
2answers
239 views

Trouble parsing JSON with getBodyParams()

I'm trying to use getBodyParams() to parse a JSON posted to a module controller action from an API. The incoming headers have content-type set as application/json; charset=utf-8, and I've tested to ...
1
vote
2answers
157 views

How do I access the checkbox field column value as a PHP array?

I have a checkbox field for dining cuisine types and I see that the checked options are stored as a JSON-encoded array in the content table. If I have an element that uses this field, is there a way I ...
1
vote
1answer
45 views

Saving a SuperTable field within a Matrix Field

I am trying to save a SuperTable field that sits within a Matrix field. I have followed the docs as far as I can but for some reason the SuperTable data is not getting saved. My steps are as follows:...
1
vote
1answer
24 views

How can I set the isCompleted status of an order from within a custom module?

The default behaviour for commerce is to mark the isCompleted flag on an order to true once the order has been paid for. I have need to alter this behaviour and only want to mark an order as Complete ...
1
vote
1answer
172 views

Render template from Module in twig template

I have been searching around SE and the web in general for an answer to this. There seems to be plenty of solutions but none appear to be working for me. I have a simple module that has a variable ...
1
vote
1answer
69 views

Add rows to editableTableField via custom javascript

I am making a custom field via a module. I have an editableTableField that will hold the actual field values saved to an entry and I have other HTML elements that are used to grab data from a ...
1
vote
1answer
174 views

Modifying Slug on FeedMe Import

I have the following Module loaded into my system, following the Event's on the FeedMe documentation I've implemented the following to change the slug per entry import but unfortunately, it's ...
1
vote
1answer
127 views

Trouble calling service methods from primary module class

I created a module for Craft 3 using pluginfactory.io, and am unable to call services from the primary module class using $this->orders->method() as shown in the documentation. The services ...
2
votes
1answer
98 views

Module not loading unless bootstrapped

I'm expanding my Craft website with a small Module, internal to this project. The module currently only defines a new input-field (extending craft\base\Field). I have dumped the autoloader from ...
1
vote
1answer
37 views

Is it possible to create this type of custom field?

We need a field that holds assigned postal codes. Each Location entry will have this field and I'd like to have the following: Buttons to assign postals by city, state, county (data grabbed from ...
2
votes
1answer
66 views

Create Matrix Block via Module

I'm having an issue creating a matrix block from a module. I'm currently doing the following: Calling an API using Guzzle Getting that request and iterating over a media block. Trying to create a new ...
2
votes
1answer
1k views

“Failed to instantiate component or class” when calling Craft module

I created a module with the pluginfactory generator. The module is used for generating a zip file with all the files belonging to a project. In the composer.json file, I added the following: "...
1
vote
0answers
55 views

How do I correctly upload a new Asset from a temp file I generated from a service method?

Preamble Craft 3.1.26 PHP 7.2.8 on Mamp Pro 5.1.1 I browsed to my storage/reports folder and made sure in Finder than full read/write privileges are granted. What's goin on I have a module with a ...
0
votes
1answer
96 views

Call Module Function from Front End

I'm looking to call the following Module function from a front end form. I've looked through numerous answers but I can't seem to find a definitive answer on this. Here's my Module's code, but ...