Questions tagged [modules]

Questions related to Craft 3 Yii Module Development

Filter by
Sorted by
Tagged with
0
votes
0answers
12 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
27 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
23 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
46 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
11 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
30 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
11 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
17 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
20 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
23 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
63 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
63 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
30 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
41 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
98 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
79 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
29 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
89 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
55 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
30 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
77 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
57 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
54 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
41 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
194 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
146 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
42 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
23 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
158 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 ...
0
votes
0answers
21 views

Twig Include is displaying empty modules on page

I have a twig file called "Abilities.twig" inside abilities I have the below code: <p>{{ module.Ability }}</p> In the CMS I have a field set named "modals" with the field block "...
1
vote
1answer
65 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
164 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
114 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
79 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
52 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
51 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
91 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 ...
1
vote
2answers
329 views

Simple Module in Craft CMS 3

How do I create a simple module for one website in Craft?. I don't have much experience in Craft CMS. I have tried from 3 days but I cannot get an answer. I'm following all the tutorials that I can ...
1
vote
1answer
36 views

Add field to /settings/sites/new (multi-site)

I would like to add some fields to the site creation on the control panel settings. I know you can add globals for each site, but I think it would be a better process if I could add additional fields. ...
1
vote
1answer
493 views

How do I correctly send an external request to a module controller? runAction() is returning null

Craft 3.1.18 I have a simple controller VeteransController made using the updated Business Logic module. The purpose of this controller is to create a very simple endpoint for an external Vue ...
1
vote
1answer
298 views

Custom module that can define and have settings referenced (Craft 3)

I'm currently working on migrating a Craft 2 project which has a bunch of bespoke custom plugins that provided various bits of additional functionality that's tailored to this project only. I've been ...
1
vote
1answer
320 views

Modules - CP Template not found

I've used this tool to generate a module: https://pluginfactory.io/ So in my constructor, I have Event::on(View::class, View::EVENT_REGISTER_CP_TEMPLATE_ROOTS, function (RegisterTemplateRootsEvent $...
1
vote
0answers
47 views

Looping over categories, product variants, and subsequently applying adjuster(s)?

Using the Craft 3 and Commerce 2 APIs, how would one go about looping through products in the cart to apply adjusters, looking at the following example; A category, "Product Packs" is set up where ...
0
votes
1answer
96 views

Create different types of Donation purchasable? (for Gift Aid etc)

The new donations purchasable looks super handy for charity websites, thank you for this :) In the UK we have a thing called Gift Aid that allows charities to claim an extra 25% on donations/...
1
vote
1answer
173 views

How to pragmatically set registered user status to pending and then manually send activation email

I have 2 front end registration forms. One for normal users and one for admins. In each form I have a hidden input with a group value like so: <input type="hidden" name="group" value="ypo"> In ...
1
vote
0answers
95 views

How do I use a relation field in an element?

Currently I have a field that extends BaseRelationField, and 2 types of elements. I want the field on elements A to be able to select from elements B. So far the field itself works, which I tested by ...