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 [modules]

Questions related to Craft 3 Yii Module Development

1
vote
1answer
11 views

How do I create console commands for my module or plugin?

I would like to create a custom console command for my Craft 3 plugin. I've looked at the Yii docs and understand commands are defined using controllers extending \yii\console\Controller but cannot ...
0
votes
0answers
20 views

Limit users to one session at a time

Building a website to host webinars where subscribed users will pay a monthly fee. Need stop multiple people logging in on the same account to gain access. I'm attempting to clear all existing ...
0
votes
0answers
19 views

Incorrectly setting module template variable

Getting error: Calling unknown method: craft\web\twig\variables\CraftVariable::markAsReadModule() Trying to use a template variable that I created in my Craft 3 module, I use this module for ...
-1
votes
0answers
25 views

How can Google reCaptcha be added to the P&T Contact Form plugin (Craft 3) using a custom module?

I found this thread about the same topic, but it and the linked plugins seem to pre-date Craft 3: Integrate Google reCAPTCHA into Contact Form plugin What I'd like to do is add Google reCaptcha using ...
1
vote
1answer
27 views

How do I delete an asset with module or plugin

I'm trying to clean-up the assets in a specific folder that aren't being used at all, i.e. aren't related to anything. I got the list O.K. just using this $assets = Asset::find()->volume('artists'...
2
votes
1answer
16 views

Some (but not all) controller action routes return 404 on staging server

I've created a module for a project that has several actions, all of which are called through AJAX. Each is a post request that sends over any required params plus the CSRF token using the method ...
2
votes
1answer
47 views

Craft 3 Custom Field Type with a File Uploader

I have a custom field type I am porting from Craft 2 to Craft 3. This field type used prepValueFromPost to grab a reference to a just uploaded file and then saves said file to an appropriate place ...
1
vote
1answer
42 views

How can I conditionally resave entries based on the value of an entry's field in a Craft 3 Module/Plugin?

Scenario: I want to programatically bulk resave entries in a certain Site in a certain Section of a certain Type. I have a Craft 3 Module with a Console Controller containing following code: public ...
1
vote
0answers
20 views

Installing module via composer

I followed this question like: ... "repositories": [{ "type": "vcs", "url": "git@bitbucket.org:jorgeanzola/mymodule.git" } ], ... "require": { "craftcms/cms": "^3.0.0", ... "...
0
votes
0answers
12 views

How to prevent Craft Admin from displaying “Leave site?” message for custom fields

I'm using custom fields provided by a Craft 3 Module to provide some Javascript-based functionality in the Craft Admin, and it includes some form elements, but the values of those form elements are ...
1
vote
1answer
22 views

List Modules in Craft System Report

Plugins and application information is detailed in the system report. Is it possible to get my module to list itself there? And if not, is there somewhere else in the CMS to see modules that a ...
1
vote
1answer
23 views

Module: EVENT_AFTER_SAVE_ELEMENT won't detect changed user group

Event::on(\craft\services\Elements::class, \craft\services\Elements::EVENT_AFTER_SAVE_ELEMENT, function(Event $event) { if ($event->element instanceof \craft\elements\User) { $user = ...
2
votes
1answer
56 views

How can I set new user accounts to pending status in a Craft 3 module?

I have the following code in my site module: Event::on( User::class, User::EVENT_BEFORE_SAVE, function (ModelEvent $event) { /** @var User $user */ $user = $event->...
1
vote
1answer
57 views

How can I rename an asset file on upload when an entry is saved (Craft 3)?

I have an entry type that includes an Assets field. When this entry is created/saved via the CP or a front-end form, I want to rename the Asset file as follows: Entry's author id. E.g: 148 01, 02, 03 ...
1
vote
1answer
46 views

Demo repo for an Adjuster module for Commerce 2?

Would it be possible for someone to create a demo of a barebones Adjuster module, similar to https://github.com/cliveportman/craftcommerce-adjuster but for Commerce 2? I'm trying to follow the docs ...
1
vote
2answers
29 views

Craft CMS module composer dependancy

After some research surrounding this I can't seem to fix this issue. So for a project I made a simple module with some variables that simply has to make an OAuth1 call and return some data. The ...
0
votes
0answers
35 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
2answers
67 views

How can I use the entry UID in the entry URI

The entries in my Craft app need a unique ‘non-guessable’ URL, so I figured I could use the UID in the URI of the entry. So in the section, where I need to provide the URI format I entered "section-...
1
vote
1answer
30 views

How to enable changing the status of my own Element Type

So i have created my own Element Type and enabled statuses with the hasStatuses() method. In the ControlPanel its shown that each element has its own status, but it cant be changed. See image below: ...
1
vote
0answers
29 views

Get fields of requested entry in module

Instead of writing a lot of logic in twig in my template, I tried to create a service and get the fields related to the requested entry in a module. I then want to create a new twig variable to output ...
1
vote
1answer
124 views

Getting a 'ReflectionException' error, "Class modules\Module does not exist' when I change the namespace of my module in Craft 3

First attempt at making a module. So far all I've done is try to change the namespace of the template that was included with my freshly installed craft 3.0.23.1 project. Was following the official ...
0
votes
0answers
24 views

Is there a callback for post Craft 3 CMS installation I can use?

I was hoping to have my module create a few fields, sections, and entries after the Craft 3 CMS has completed it's installation. Is there a callback I can listen to that triggers after the CMS is ...
1
vote
1answer
152 views

Basic Module Tutorial or Example

I am having a difficult time understanding how to output even a simple variable using a module. Ultimately I have PHP code that I need to execute to generate a PDF. I managed to do this in V2.5. I'm ...
0
votes
1answer
26 views

Removing “action” from a module's route. Is it possible?

I have a module with a route that looks like this: http://localhost/actions/module/controller/action Is it possible to set up a custom route within my module so I can send people to: http://...
1
vote
1answer
180 views

“Template Not Found” error when trying to access a module controller action

I'm a total Craft newbie, so I hope this question isn't ridiculous. I just want to see a controller / action work in my new module. I have src/controllers/ScrapeController.php as such: <?php ...
2
votes
1answer
179 views

Running module migrations

I must be missing something or not understanding something. I'm trying to build a module for an install, and I'd like to run the initial migration. So the module initial install migration for the DB ...
1
vote
1answer
272 views

How to render a template from within a module?

I'm currently developing a module that contains a custom field and I'd like to create a template to be used in the getInputHtml method. I try using the Craft::$app->view->renderTemplate method ...
1
vote
1answer
79 views

How to develop plugin/module to build landingpage upon fetched JSON-data

I've developed an app which fetches data from an API based on Laravel 5.5. The marketing landingpage of the app is based on Craft CMS Version 3. The marketing website and the API and the databases of ...
3
votes
1answer
216 views

How can I install modules with Composer?

Installing a Craft 3 plugin via Composer is pretty simple. You require the package, update Composer, and install it via the CMS. My circumstances require that our company use a private Module on all ...
0
votes
0answers
41 views

How to best run a custom PHP script in craft 3? [duplicate]

I have a php script for displaying delivery tracking information which runs independent from craft. It should run on a craft website on a specific page like so https://mypage.com/tracking/?content=...
1
vote
1answer
55 views

Craft 3 attachment email

I need to add an "attachment" to an email sent by Craft CMS 3. I used a custom "Module" for this with a "Model", "Service", "Record" and "Controller" I did some research but did not find any clear ...
1
vote
1answer
160 views

Yii Modules in Craft, samples?

Does anybody know of a collection or library of Yii Modules online? I'm trying to understand how easy they can be moved from one application to another, are we going to see something similar to the ...
1
vote
1answer
502 views

How to call Controller in Module?

I'm very new to craft and I'm having trouble finding an answer to my question (I've scoured the questions on here - but the only answers appear to be for plugins). Basically, I want to submit a form ...
1
vote
1answer
179 views

Return the contents of a template from a custom Twig function in a module?

I have a template that outputs some JSON formatted data. I've built a simple module that needs to get the contents of that template, decode the JSON data, and return it. I believe I need to use ...
1
vote
1answer
236 views

How do I load composer dependencies for a Yii module that's in my site repo?

I have a site-specific module in my modules directory that's being loaded in config/app.php. Since it won't be used elsewhere I am not storing the module in an external repository. When I added a ...