Questions tagged [craft4]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
199 views

Undefined array key "permissions" error after upgrade to Craft4

Hi need some help here. I recently I tried to upgrade Craftcms from Craft Pro 3.7.55.2 to Craft Pro 4.3.6.1, there is no error in migration, but when I try to edit a user group, I got this error: [web....
Thomas's user avatar
  • 69
1 vote
1 answer
22 views

How to change file path where the Debug Toolbar's debugger files are stored?

According to Pull Request #10825 for Craft 4, you can override the filesystem and path where the debugger files are stored for the Debug Toolbar. In the absence of using a separate filesystem, I'd ...
jrrdnx's user avatar
  • 153
1 vote
1 answer
51 views

How to check read-only mode in plugin?

I have written a plugin and it listens to different events to run some tasks. Now if the app is in "read-only mode", I do not want some of these events to run: class MyPlugin extends Plugin {...
7ochem's user avatar
  • 163
1 vote
1 answer
347 views

Craft CMS 4 custom orderBy

Is there a way to sort entries by a customSortOrderFunction in a plugin? Like: craft.entries.section('somename').orderBy(myCustomSortOrderFunction) Where myCustomSortOrderFunction returns some data ...
Felix's user avatar
  • 11
1 vote
1 answer
191 views

Feedme Only running Cron jobs when logging in

I've created a cron job that runs my Feedme feeds on an hourly basis. The issue is, when logging in I see all the jobs queued up, but they only start running when I actually login to the dashboard, is ...
JMKelley's user avatar
  • 1,384
1 vote
2 answers
246 views

Defining a domain for each site for both production and local - craft 4 multisite

I have a craft 4 multi site, each site has its own domain. In the cp settings for each site I have entered each domain. This works fine for the production environment but is obviously useless when ...
George Bleasdale's user avatar
1 vote
2 answers
363 views

Craft 4 slow on DDEV OSX Monterey

Set up my first Craft 4 install locally on DDEV on OSX Monterey, followed the install guide here https://craftcms.com/docs/4.x/installation.html#quick-start Seems to be working fine except its slow, ...
Graham Bennett's user avatar
0 votes
0 answers
147 views

Debugging slow loading Control Panel (and front-end too)

Craft CMS take a very long time to load, sometimes over 5-6 seconds (in my local environment WAMP). Profiling with Yii Toolbar I can see that (a page in the Control Panel) : The site is running ...
fr123's user avatar
  • 1
0 votes
1 answer
208 views

Eager-loading in a page builder built on NEO field

Upon upgrading to Craft 4, I've realized that I should implement eager-loading in quite a few places as suggested by the Blitz caching plugin. Most of these are within our page builder, which is built ...
InanisAtheos's user avatar
1 vote
1 answer
206 views

Prepopulating image fields - Formie Plugin on Craft 4

I have a front end entry form for users to update their entry. It's built using the Formie plugin. I need the fields to prepopulate with the current entry content. According to the Formie docs fields ...
George Bleasdale's user avatar
1 vote
0 answers
34 views

How to detect when a custom Field's element is being hard deleted?

With a custom Field how do you detect before the element associated with the field is hard deleted not just before it is soft deleted (beforeElementDelete) and added to the trash.
a-am's user avatar
  • 2,857
0 votes
1 answer
46 views

Deleting a matrix block type that was copied in code

I'm somewhat new to Craft, and struggling a bit with copying matrix block types. Any help would be greatly appreciated. So, I have some code that copies a matrix block and its fields, but when I go to ...
Eli's user avatar
  • 21
1 vote
1 answer
173 views

Front end entry form not saving on Craft CMS 4 multisite

I have created a basic entry form that simply saves a title but I can't seem to get it working. I copied the code from Craft's documentation but that didn't work so I tried copying the code from ...
George Bleasdale's user avatar
0 votes
0 answers
45 views

Trouble with channel URLs and CSS files not pulling through - Craft CMS 4 Multisite

I'm building a multisite on Craft CMS 4 and I'm having trouble with channel URLs. At the moment I'm working locally and then pushing it to the hosting via github. I've created a folder for each site ...
George Bleasdale's user avatar
1 vote
1 answer
48 views

Save Entry form values as Draft to translated site versions on a single submit

I have an Entry field layout where only a few Plain Text fields are translatable. Users can edit these Entries from front-end, and I'm looking for the most efficient way to let them save the ...
Romain P.'s user avatar
  • 1,808
1 vote
1 answer
32 views

How do you get Craft to generate multi-paragraph text?

In every other CMS I've used there's an option to compose multi-paragraph text in the back end which is then parsed out into P tags in templates. Neither the native text field nor the popular Redactor ...
Tim Murtaugh's user avatar
1 vote
2 answers
68 views

Postgres DB Schema not referenced when accessing web url but craft cmd works fine?

I'm having a strange issue when accessing a craft instance via the web yet the craft cmd works fine. When resolving the URL it's throwing a 503 and the logs are showing an issue with fetching data ...
Rich D.'s user avatar
  • 45
0 votes
0 answers
58 views

"Craft Isn’t Installed Yet" Error - Asset Indexes

I have a Craft 4 site — all working fine. If I go to Utilities > Asset Indexes > Update Asset Indexes, I get the following error: "Craft isn’t installed yet." Clearly, this is not the ...
mitrol's user avatar
  • 262
2 votes
1 answer
192 views

Migrating a Craft 4 instance from MySQL to PostgreSQL

I've managed to convert a fairly basic Craft 4 MySQL db to PostgreSQL using the pgloader tool, which came with it's own auth related issues when running PSQL v14+ instance - see https://github.com/...
Rich D.'s user avatar
  • 45
1 vote
1 answer
500 views

Craft 4 - Mul­ti-Fac­tor Authen­ti­ca­tion

I am looking to implement Mul­ti-Fac­tor Authen­ti­ca­tion on Craft Admin. In this article, it seems to be added to Craft 4 : https://craftquest.io/articles/what-new-features-are-in-craft-cms-4#multi-...
emilie zawadzki's user avatar
0 votes
0 answers
172 views

getDiscountByCode(): Argument #1 ($code) must be of type string, null given

I migrated to craft 4 according to the migration guide and everything went well. Steps to reproduce Migrate to craft Add something into the cart On the Cart template there is the following error on ...
KSPR's user avatar
  • 3,776
1 vote
1 answer
46 views

How can I add a zip folder to an asset field in craft cms

I'm quite new to the cms and would like to know how to programmatically add a zip folder to an asset field in craft cms using a plugin. So like listening to ENTRY_AFTER_EVENT and processing a zip ...
Iron Brew's user avatar
1 vote
2 answers
530 views

Craft 4: How do I get field by handle?

In Craft 2, I used to be able to do this: https://craftcms.com/docs/2.x/templating/craft.fields.html#getfieldbyhandle-handle {% set body = craft.fields.getFieldByHandle('body') %} {{ body.instructions ...
Tchick's user avatar
  • 105
1 vote
1 answer
743 views

Using EventStream doesn't work because MimeType from Controller Action is always text/html

I'm trying to listen to SSE events from a controller action. I am setting the headers in the controller action with: Craft::$app->response->headers ->set('Content-Type: text/event-...
Tudor-Radu Barbu's user avatar
1 vote
1 answer
104 views

Set asset volume dynamically via module depending on uploaded file kind

I'm trying to set the asset volume dynamically for new assets, using a module. I would like the volume to be based on the asset's file kind – in my case, automatically putting MP4s into a 'Videos' ...
Josh Harrison's user avatar
1 vote
1 answer
21 views

Is there a way to mutate categories through GraphQL for a specific siteId?

The graphQL does not support siteId parameter in category mutation. How could I mutate the content for a specific siteId?
user13530's user avatar
1 vote
1 answer
181 views

Webp not available in image transformations although set up

I have already done some research and have not found anything related to my specific problem. Quite some time ago I installed Imagick on my VPS and thus enabled the use of the Webp image format in the ...
Dave's user avatar
  • 31
1 vote
1 answer
311 views

Getting unknown property: craft\fields\Dropdown::contentTable

I've upgraded to craft 4.3.1 Now I can no longer delete fields: 2022-11-16 14:02:47 [web.ERROR] [yii\base\UnknownPropertyException] yii\base\UnknownPropertyException: Getting unknown property: craft\...
KSPR's user avatar
  • 3,776
1 vote
1 answer
373 views

Updating to Craft 4 breaks plugin settings: must not be accessed before initialization

I maintain a plugin. Inside this plugin's composer.json, extra>handle is set to pizza (not the real name). In one of the controllers, the following code is executed: $apiKey = Plugin::$plugin->...
Paul Hübner's user avatar
3 votes
1 answer
282 views

Contact Form is not working anymore since upgrading from Craft 3 to 4

After upgrading to Craft 4 non of my Craft Forms are working... getting the error "Symfony\Component\Mime\Address::__construct(): Argument #2 ($name) must be of type string, null given, called in ...
Marcel Boer's user avatar
1 vote
1 answer
150 views

How to programmatically create category groups and categories in Craft 3/4

I am struggling to create a new category group and category programmatically. I've found a few examples for creating an entry, and one for creating categories in Craft 2, but I can't get it working in ...
Garrett's user avatar
  • 417
0 votes
1 answer
50 views

How to enforce subfolder names for uploaded assets in hierarchical related sections

My goal is to ensure uploaded videos are organized into folders like: /Show/Season/Episode/videofile.mp4 Or stated another way... /{{ Show ID of grandparent }}/{{ Season ID of parent }}/{{ Episode ...
Jim's user avatar
  • 139
1 vote
1 answer
75 views

Attach a User Element to another User via user registration frontend form

I am trying to prepopulate a hidden field on frontend user registration from with another user element... to explain better:any client user could be connected to an agent user, if a parameter (agentId)...
Masiorama's user avatar
  • 205
1 vote
1 answer
427 views

Update to Craft 4 causing CORS error on login to CP on live site only

I have recently updated a website to Craft 4 and all went well, but now I cannot login to the Control Panel as I'm getting an error: Access to XMLHttpRequest at 'https://www.xxx.com/index.php?p=...
randomPenguin's user avatar
1 vote
1 answer
159 views

How to rename an asset on file upload Craft 4

I am looking to update some custom module code which updates the file name on upload. In Craft 3 I had this working by listening to the EVENT_AFTER_SAVE on an Asset. It would detect the ID of the ...
zizther's user avatar
  • 449
0 votes
1 answer
128 views

Upgrading to Craft 4 dosen’t seem to work

I went through the upgrade guide step-by-step and all went smoothly without error. But my Craft Installation is still running in 3.7.57. I logged out and in again, it still runs Craft 3. Also repeated ...
user2190590's user avatar
1 vote
1 answer
485 views

Element query executed before Craft is fully initialized

I'm getting that warning in my log since updating to Craft4. I've traced it to a problem with my config/contact-form.php. This is a modified version of the suggested code for Dynamically adding email ...
Paul Frost's user avatar
  • 1,060
0 votes
2 answers
374 views

Log warnings "..before Craft is fully initialized"

After updating a site from 3.7 to 4.2.8, in Dev mode and showing the debug toolbar and loading a really simple page (or the control panel) I'm seeing warnings in the log. I repeated the update process ...
Paul Frost's user avatar
  • 1,060
1 vote
0 answers
94 views

Craft4 Upgrade did not create filesystem entries

I'm making a post about this as a form of documentation of an issue I ran into while upgrading one of my sites to Craft4. I followed the upgrade instructions and got the site upgraded to the latest ...
Rick Kukiela's user avatar
2 votes
1 answer
218 views

Installing plugins in fresh Craft4 install causes error of identifying as older plugin version

I tried upgrading to Craft 4 (4.2.5.1), and Feed Me and Super Table would not upgrade properly, causing Craft to crash. When installing the compatible versions, old version numbers populate in the db, ...
jstevens79's user avatar
0 votes
1 answer
22 views

CP Edit Columns only possible for admins?

I just found out that non-admin users can't edit the columns shown for the entries. Is there a way to activate this for non-admin users as well?
obs's user avatar
  • 499
0 votes
1 answer
254 views

Craft Commerce PayPal Checkout: Error: Expected an order id to be passed

I am having big trouble getting the PayPal checkout plugin to work. I am using this code: {% namespace cart.gateway.handle|commercePaymentFormNamespace %} {{ cart.gateway....
Volker Andres's user avatar
0 votes
2 answers
198 views

Macros: Variables inside of variables

I have a slightly mind bending question. Here's my setup: file.twig {% set entries = craft.entries({ section: 'events').all() %} {% set tileContent %} <p>{{tileEntry.title}}</p> {% ...
Adrian's user avatar
  • 437
1 vote
0 answers
43 views

cannot create matrix in craftcms 4.2.3

I just created a fresh project with craftcms 4, but am running into issues creating a matrix. Even with just one block field. It gives me the error Cannot assign string to property craft\models\...
jbrightdev's user avatar
1 vote
1 answer
108 views

Using index hints to get around performance issues with large structures table

We're experiencing performance issues in CP stemming from having a decent number (>20k) of records in structures and the mysql is using the wrong index (dateDeleted instead of primary). This issue ...
SeanJ's user avatar
  • 21
0 votes
1 answer
247 views

Navigation from structure with field Entries for URL

I am new to craftcms and searching did not get any answer. I have 2 fields setup navUrl (type entries) and customUrl (url) and I have a section called mainMenu with these fields. I have then added the ...
Thiag's user avatar
  • 1
0 votes
1 answer
720 views

Not instantiable – yii\di\NotInstantiableException when setting and reading cookies

Hello, within a craft template I query the existence of a cookie to visually highlight new entries in the CMS with CSS. This worked for a long time without any problems. A visitor told me that on ...
Andreas Ploch's user avatar
0 votes
0 answers
93 views

Set maximum quantity at the product level

I am trying to figure out a way to set a maximum quantity at the product level instead of on the individual variants. The specific use case is selling tickets to events, where my client needs to be ...
Peter U's user avatar
0 votes
2 answers
52 views

Shared Static Assets for Multilingual

I'm trying to do a multilingual site e.g. /nl /de though when browsing to these URL's all is working apart from the static images hosted in .../nl/web/img it seems to be looking for URL's still within ...
JMKelley's user avatar
  • 1,384
0 votes
3 answers
97 views

Get section handle of an entry inside of an EntryField

Maybe Craft 4 is playing games with me but im stuck on this problem: linkedEntry is an entry field which is limited to 1 entry. This outputs the section handle correctly {% set linkedEntry = ...
Leonardo's user avatar
  • 431