Questions tagged [craft4]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
5 votes
1 answer
2k views

Uncaught TypeError Dotenv Create on updating to Craft CMS 4

Just updated to Craft 4, migrated my /web folder over as well as my /assets folder and trying to load the index page gives me the following error. Any help would be great as I can no longer access my /...
JMKelley's user avatar
  • 1,374
4 votes
2 answers
330 views

Craft 4 upgrade. Entry throwing 'craft\models\EntryDraft doesn’t exist' error in admin

After upgrading to Craft 4 a few entries are throwing this error in the admin (Locally): craft\models\EntryDraft doesn’t exist or doesn’t extend/implement craft\base\ElementInterface Not all do this ...
Martin's user avatar
  • 43
4 votes
2 answers
816 views

Craft 4: using the new laravel collections and related methods (in a performant way)

I am working on a website for a radio that publishes its programs as podcasts with episodes. Each of the 30 or so programs potentially has a lot of episodes. Each entry in the episodes channel has a ...
Jérôme Coupé's user avatar
3 votes
1 answer
246 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
3 votes
1 answer
1k views

Upgrade to Craft 4

Anyone succeeded in upgrading from Craft 3 to Craft 4 ? Before staging the changes on our dev server, I tried it locally without success. Although it seems pretty strait forward, I updated all plugins ...
Sylvain Tremblay's user avatar
2 votes
2 answers
2k views

Questions about Craft 4 release and licenses

Being busy rethinking an existing website to rebuild in Craft I just found out Craft 4 was announced september last year. Some of the new features, like nestable Matrix fields in particular, are very ...
Friksel's user avatar
  • 180
2 votes
1 answer
369 views

Craft 4: How to programmatically attach fields to entry type tab

I'm in the process of upgrading a plugin from Craft 3 to Craft 4. When the plugin is installed it creates some fields and attaches them to an entry type. The way it was done in Craft 3 is: Get the ...
Matanya's user avatar
  • 452
2 votes
1 answer
173 views

Parent based Selectable Entries Condition

In the Craft CMS admin, I have an entries field on a page, and I want to limit the selectable entries available to only the child pages of the current entry. To achieve this, I set the Selectable ...
Mike Niland's user avatar
2 votes
2 answers
231 views

Delete Entry on Front End Form (Craft CMS 4.x)

Hello — been reading up on how to do this and there are some posts for Craft 2, 3 — but I'm not sure what's out there works for Craft CMS 4. I am using the following JS to delete an entry. However I ...
Adrian's user avatar
  • 427
2 votes
2 answers
130 views

Nitro: how risky is it to dev using MariaDB and then go live with MySQL?

Nitro does not support MySQL for Apple Silicon, but you can use MariaDB interchangeably. I'm using an Apple Silicon computer, and my server run with MySQL only. However, as read in the Craft Database ...
Romain P.'s user avatar
  • 1,798
2 votes
1 answer
25 views

Get list of user logins

I would like to get a list of every login of a user. I know I can get a certain user with craft.users() but as far as I have seen, I get data for lastLoginDate only. Is there a way to get a complete ...
obs's user avatar
  • 487
2 votes
1 answer
57 views

New Laptop - Developing Existing Project Locally

I've got a craft cms 4 website that I've been developing locally on my old PC and I've also got hosted with Servd Host. I've just got a new mac and I'm trying to get my project running locally on it ...
George Bleasdale's user avatar
2 votes
1 answer
40 views

200 new lines in elements_sites per entry

I noticed that the ID number of my entries has increased to almost 50.000, but I have around 1.000 entries and 2.000 files. I understand that other things like categories also affect that number, but ...
H.W. Sanden's user avatar
2 votes
1 answer
46 views

Multisite - Save the draft only to the site it was created in

I'm working on the multisite in Craft4 - 2 identical sites, but the text is in different language. I have a section with the Propagation Method set to Save entries to all sites enabled for this ...
Michal Bulla's user avatar
2 votes
1 answer
104 views

OPcache extension Warning

I updated my Craft installation to 4.5.3, right? And then I noticed this warning pops up in the system report, saying, "The OPcache extension is recommended in production environments." ...
JBrew30's user avatar
  • 102
2 votes
1 answer
158 views

Mutagen in DDEV Making Craft CMS Slow to Propagate

This is related to a previous question. When I have mutagen enabled in DDEV, it takes around 20 seconds for any changes to propagate. Even things as simple as updating a few lines of text in a twig ...
darkbasic's user avatar
2 votes
1 answer
75 views

Resaving Matrix Blocks skips because of "not loading its content"

We recently updated one of our biggest projects to Craft 4. And today I tried to resave all the matrix block with resave/matrix-blocks but was greeted with the following behaviour: Does anybody have ...
Leonardo's user avatar
  • 419
2 votes
1 answer
185 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
2 votes
1 answer
170 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
2 answers
1k views

Craft 4 Custom Variables - From Env > General.php > template

Been trying for a wee while, but no joy so far. This worked in Craft 3, but not in Craft 4. It's a CSS cache buster, I basically want a variable to set in env, then taken into general.php[caveat] and ...
John Macpherson's user avatar
1 vote
3 answers
63 views

Debug Toolbar Not Displaying on frontend

I just updated a site to Craft 4 and the debug toolbar no longer shows on the frontend, but does show in the CP. Have not had this issue with other sites that were updated. Any ideas?
Roi Agneta's user avatar
  • 1,413
1 vote
1 answer
183 views

PHP version problem when upgrading to Craft CMS 4

I am upgrading a site from Craft CMS 3 to 4. I develop the site on ddev with docker desktop on Windows. When running composer update on PHP 7.4 and docker 2 on ddev the following happens: $ ddev ...
nitech's user avatar
  • 679
1 vote
1 answer
157 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,374
1 vote
1 answer
294 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
1 vote
4 answers
270 views

Craft 4 doesn't support other languages yet?

After installing a fresh version of Craft 4, the setup didn't allow me to specify the site language fr-FR as it did with the previous version. I had to accept the default en-US. I thought that I would ...
fdelaneau's user avatar
  • 123
1 vote
1 answer
62 views

Craft CMS 4: Update without proc_open

I've recently managed to upgrade my Craft installation from 3.9.1 to 4.5.0. During the upgrade process I had a number of times where the update process from within the admin GUI 'failed' or at least ...
Marty's user avatar
  • 11
1 vote
1 answer
75 views

Run craft up command in deployment pipeline without prompts

I am deploying a Craft website with Bitbucket Pipelines. Basically what it does is spinning up a container that runs composer install and builds my CSS and JS with webpack. The vendor folder and js/...
Matthias's user avatar
1 vote
2 answers
179 views

Craft 4, CKEditor 5, image resizeOptions not showing in image toolbar

I'm experimenting with all the CKEditor 5 config options and I like how the docs have the image resize (https://ckeditor.com/docs/ckeditor5/latest/features/images/images-overview.html#image-contextual-...
Amanda Lutz's user avatar
1 vote
1 answer
55 views

Error when Project.yaml Migration from Local

I'm getting the following error when migrating the project folder over to my live environment. Never had this before and unsure what to do. error: SQLSTATE[42S02]: Base table or view not found: 1146 ...
JMKelley's user avatar
  • 1,374
1 vote
1 answer
178 views

After upgrade from Craft 3 to 4: frontend error: Array to string conversion

After upgrading from Craft 3 to Craft 4, the backend is accessible but the frontend displays the error: PHP Warning – yii\base\ErrorException Array to string conversion And points to many files: ...
BrokenCode's user avatar
1 vote
1 answer
73 views

Craft installation fails with SQL error (PostgreSQL)

I am trying to install the Craft CMS (Version 4.4.1) on a VM in the Azure Cloud with PostgreSQL 13.9 as managed Azure Service. The error i'm running into is the following: *** failed to install Craft: ...
Boris's user avatar
  • 41
1 vote
1 answer
113 views

Craft 4 Building a Plugin not saving all properties

After following the "How to build a plugin" from the official CraftCMS docs, I've started extending the Control Panel Template from 1 to multiple fields, all are of the same type string and ...
funkysoul's user avatar
  • 113
1 vote
1 answer
360 views

How to send email from Craft 4 custom plugin/module?

I want to send an email using crafts mailer in Craft 4. I've seen this post: How to send email from Craft 3 custom plugin? But now I need this adapted for craft 4. Unfortunately I did not succeed so ...
Merc's user avatar
  • 211
1 vote
1 answer
43 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
  • 161
1 vote
2 answers
195 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
55 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
1 vote
2 answers
440 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
2 answers
150 views

How to programmatically enable Pro trial in Craft 4?

In Craft 3, I setup a base build for my team which had a bash script. At one point in the script I was able to enable a Craft Pro trial license like so: echo 'Craft::$app->setEdition(Craft::Pro)' | ...
Plum Duffer's user avatar
1 vote
1 answer
897 views

Craft4 stream_copy_to_stream(): Argument #2 ($to) must be of type resource, bool given

As mentioned in the title, I'm not able to upload any files in Craft4. I created a filesystem and a volume which is connected to the filesystem. In the assets-field settings I added the volume. I have ...
mcoze's user avatar
  • 41
1 vote
1 answer
28 views

Omit specific URLs from the sitemap

I want to exclude certain URLs from the sitemap, depending on the custom field settings in their corresponding entries. I'm using SEO Matic plugin in craft4
Thangaraj Moorthi's user avatar
1 vote
1 answer
37 views

Image Editor: Remove "focal point" and "custom"

Is there a way to remove "focal point" and "custom" options from the image editor? Custom ratios are documented here: https://craftcms.com/docs/4.x/config/general.html#image-...
Marc 's user avatar
  • 75
1 vote
1 answer
65 views

Create deep copy of twig variable

I'm building a filter page with Craft and Sprig. The goal is to show the amount of products for each filter. So for example if we want to filter on color we show 2 checkboxes "Red" and "...
Matthias's user avatar
1 vote
2 answers
36 views

Conditional - Apply After Every Third Loop

The following is messy and obviously not scalable. There must be a way in twig to target a common difference of 3 right? {% if loop.first or loop.index == 4 or loop.index == 7 or loop.index == 10 %} ...
Jason McKinney's user avatar
1 vote
1 answer
60 views

How to completely disable entry versioning(drafts) during editing

Obviously I disabled it in the section settings: I just want to save the entry after making all the changes, but now it's trying to save the revision after each single change
Nikolay Bronskiy's user avatar
1 vote
1 answer
27 views

Plugin migration - how to handle count in php8.1

I am trying to migrate a plugin from Craft 3 to Craft4 . The plugin basically checks the entry for a pdf asset and create a thumbnail asset from the PDF using Imagick to save with the entry. I use to ...
joomkit's user avatar
  • 2,004
1 vote
2 answers
60 views

GraphQL queries for srcset

I am trying to fetch srcset with GraphQL from Craft4 but I don't really understand the syntax. In my twig Templates I use image.getSrcset(['1x','2x'],'myTransformHandle') and I'm trying to translate ...
thomas's user avatar
  • 131
1 vote
2 answers
34 views

Help building a query with related to

I'm trying to create an or query with 2 related fields and 1 title field. My version so far is this: $searchQuery->where([ 'or', ['relatedTo', 'targetElement' => $ids, 'field' => '...
bartpulse's user avatar
1 vote
2 answers
70 views

Entry url in console action doesn't return absolute URL

In an e-mail template in a custom plugin I want to render a link to an entry. This needs to be an absolute URL. I need this to work both when triggering the action from the control panel, and when ...
PWL's user avatar
  • 157
1 vote
1 answer
41 views

How to get second asset in Craft CMS 4?

In craft cms 3 we could use this: {{ entry.images[1].url }} But how can I get second asset in Craft CMS 4?
Nikolay Bronskiy's user avatar
1 vote
1 answer
80 views

Offset on an array (Sprig)

I'm trying to create a load more function using a filtered set of entries, then passing those entries into the Load More component using Sprig. I get the error "Impossible to invoke a method (&...
JMKelley's user avatar
  • 1,374