Skip to main content
Share Your Experience: Take the 2024 Developer Survey
4 votes

New to CraftCMS and linking to an existing project using DDEV

You will need your existing Craft CMS project on your local computer, ideally through a Git repository, but you can also copy the files down from the server into a directory on your computer. You will ...
CraftQuest's user avatar
  • 1,122
3 votes

I have an existing project called Craft cms v3.3, what should I do if I want to run it at local?(Mac OS)

Follow the getting started tutorial to learn how to set up a local development environment. The only thing that's different is that instead of running composer create-project craftcms/craft, you use ...
MoritzLost's user avatar
  • 11.4k
3 votes
Accepted

Syntax for URL route instead of using url parameter

Using routes You can define a route like this in your config/routes.php: return [ '<country:{slug}>/<city:{slug}>/<productType:{slug}>' => ['template' => '_category'], ]; ...
MoritzLost's user avatar
  • 11.4k
3 votes
Accepted

Updated to PHP version 8.1.22 and one of my Craft 3 sites is getting a critical error

Craft version 3.6.17 was released in June 2021, while PHP 8.1 had its first stable release in November 2021. The latest PHP version Craft could support at that point was 8.0, so you're running this ...
MoritzLost's user avatar
  • 11.4k
3 votes

Can't Update CraftCMS

In Craft 3 and upwards you should have a vendor folder that is created and updated with composer. You would do the update locally (I recommend docker and ddev), which will update composer.json, ...
Max Strebel's user avatar
3 votes
Accepted

Deployment strategy that removes tables from uninstalled plugins

The trick is to do it in two separate steps… Uninstall the plugin via Craft. Push those changes all the way through to your production environment. Uninstall the plugin via Composer. Push those ...
Lindsey D's user avatar
  • 24k
2 votes

How can I get cookies that were set in javascript from a twig template? [NEW]

If you want a specific cookie instead of the set of cookies, you'd use Old Craft 3 Syntax: {% set specificCookie = craft.app.request.getCookie('specificCookie') %} Deprecation Replacement (for Craft ...
cherrykoda's user avatar
  • 1,114
2 votes
Accepted

How to completely disable entry versioning(drafts) during editing

What you're seeing are provisional drafts, they aren't published until you hit enter. This is good to have so you don't lose your work if you accidentally close the browser tab or your computer ...
MoritzLost's user avatar
  • 11.4k
2 votes

It's possible to display "User" menu history like "Entries" menu history on admin dashboard

For something like the Entries widget, you'll need to code your own custom widget. There's instructions you can dig into here: https://craftcms.com/docs/4.x/extend/widget-types.html The queries you'll ...
cherrykoda's user avatar
  • 1,114
2 votes

Stop customers from increasing line item

I might be misunderstanding your situation, but Commerce has built-in min/max "Allowed Quantity" per product (per variant technically) here: Limiting that to 1 max will prevent more from ...
James Smith's user avatar
  • 5,304
2 votes
Accepted

Session token error/missing after server switch

That session path is related to cPanel with an Easy Apache install with multiple php binaries. For an error message to display that cPanel session path locally, there must be a session path hard-coded ...
colonelclick's user avatar
2 votes

Cleaning up twig query with nested and/or where

I ended up using a ProductQuery Behavior. This is quite handy as the same query is used in different pages. My final solution: Twig {% set tempQuery = craft.products() .type('product') ....
bartpulse's user avatar
2 votes
Accepted

_layouts/cp.twig cannot be found

There is ONE tiny difference between Craft 3.x and Craft 4.x! {% extends "_layouts/cp.html" %} for Craft 3 {% extends "_layouts/cp.twig" %} for Craft 4 and to avoid a future ...
cherrykoda's user avatar
  • 1,114
2 votes
Accepted

Event on new user created

Try $isNew = $user->isNewForSite.
James Smith's user avatar
  • 5,304
2 votes
Accepted

Can't use matrix.one() and matrix.all() at the same page

It is indeed confusing behaviour... The reason why it's happening, along with a handful of solutions, is outlined in the answers to this question: Offset setting a limit? As I mentioned in my answer ...
James Smith's user avatar
  • 5,304
2 votes
Accepted

Eager-loading content and merging queries

Sorry I've never used Neo before, but I'll answer as if it were a standard Craft matrix field, as I'd expect/hope that it would work the same way(?!): First, correct your syntax: In entry.modules....
James Smith's user avatar
  • 5,304
1 vote

Stop customers from increasing line item

I found a coded solution using EVENT_BEFORE_SAVE_LINE_ITEM ... but I think @JamesSmith's answer would be the ideal solution
Jaytrix's user avatar
  • 337
1 vote
Accepted

Craft 3 DDEV Migration: "No database has been selected yet"

It looks like you’re specifying a DB_DSN in your config/db.php file, but your .env file isn’t defining that variable. You either need to specify the full DB_DSN string in your .env file or update your ...
Brad Bell's user avatar
  • 67.5k
1 vote

Cleaning up twig query with nested and/or where

Ordinarily I'm a fan of being as lean and efficient as possible, but it strikes me that this where clause makes your Twig quite hard to read - as you say, getting the all the square brackets and quote ...
James Smith's user avatar
  • 5,304
1 vote

Upgrading to Craft 3.7 errors

This is likely because a previous attempt at updating failed, and the database wasn't reverted back to its prior state. Your best bet would be to import your backup from before the upgrade attempt and ...
CraftQuest's user avatar
  • 1,122
1 vote

Big upgrade completed locally, how to upgrade live?

I always php craft up after composer install, it does migrations, project config apply etc. Did you upgrade commerce to the newest version? Did you then also run the commerce upgrade command? From ...
Syversen's user avatar
  • 485
1 vote

I want to pull content from a field on an entry into a matrix block that is displayed on that entry, is this possible?

The Preparse field can be used for this. It is a field type that parses Twig and saves the result as plain text. The Craft 3 version can be found here: https://plugins.craftcms.com/preparse-field?...
Steve Rowling's user avatar
1 vote

How to differentiate between draft versions in ModelEvent?

Could you try this: Event::on( Entry::class, Entry::EVENT_BEFORE_SAVE, function (ModelEvent $event) { if (ElementHelper::isDraft($event->sender)) { ...
RomanAvr's user avatar
  • 669
1 vote

How can I list Entry Types of a single Section?

For anyone coming here and looking for a solution for Craft 5: It now works like that: {% set section = craft.app.entries.getSectionByHandle('blog') %} {% set entryTypes = craft.app.entries....
obs's user avatar
  • 541
1 vote

What is the best way to deploy a Craft CMS 3 site?

I guess you're seeing this notice, because of pending migrations after an update. After you deployed the repository, you should make sure that: Run composer install --no-interaction to install ...
Max Strebel's user avatar
1 vote

How do I solve "Unknown Property – yii\base\UnknownPropertyException Setting unknown property: craft\fields\Assets::branchLimit"

The most likely explanation is that you're trying to import a database dump that was created on a different version of Craft than the one you're running locally. The Assets::branchLimit property was ...
MoritzLost's user avatar
  • 11.4k
1 vote
Accepted

Can't disable entry versioning

You're looking for https://craftcms.com/docs/3.x/config/config-settings.html#maxrevisions It shouldn't be slow. But it's best to limit the revisions, a good setting on a multisite is maximum 3 to 5 ...
Michael Thomas's user avatar
1 vote

Help building a query with related to

Used an two step workaround by splitting it in 2 queries, merging the ids and searching by id in a 3rd query. $searchUsersIds = User::find()->search($search['rawSearch'])->ids(); $...
bartpulse's user avatar
1 vote

Help building a query with related to

I think relatedTo should not be used in that place, but should be used on the $searchQuery object instead: $searchQuery ->relatedTo([ ['field' => 'field1', 'targetElement' => $ids], ...
Paul's user avatar
  • 6,338
1 vote

Site breaking when I call a custom module up on app.php file

Without knowing what the actual error is, it's hard to help you out. Could you try and find the error in the error log, probably located at storage/logs/web.log? Error and stack trace should be in ...
Paul's user avatar
  • 6,338

Only top scored, non community-wiki answers of a minimum length are eligible