MoritzLost
  • Member for 10 months
  • Last seen this week
Exception 'yii\base\UnknownMethodException'
Accepted answer
2 votes

The problem is that this config file is for console commands as well as web requests. Console commands differ from web requests in that they don't have body parameters. For web requests, Craft::$app-&...

View answer
How to batch a large queue job?
Accepted answer
2 votes

Remember that queue jobs are run in seperate processes from the code that enqueues them. So the 100 elements you're putting in the queue need to be serialized, saved to the database and then ...

View answer
How to customize fonts with redactor font menu
Accepted answer
2 votes

It's undocumented (like all Redactor plugins), but you can configure the list of fonts used in the JSON config you assign the Redactor field in the settings. You can download the original fontfamily ...

View answer
Managing `isSystemLive` with Project Config
Accepted answer
2 votes

You can use the console commands off and on to take the system offline or online, respectively. This bypasses the allowAdminChanges setting and is explicitly intended for usage during deployments. In ...

View answer
Save metadata on entry without creating a corresponding field
Accepted answer
2 votes

I'm not sure there's a simple way to add metadata to entries without messing with the database or writing your own workaround. But if you only care about the value not being visible in the CP, you can ...

View answer
How to save an entry using AJAX on a frontend Form [ for registered users]
Accepted answer
2 votes

As per the comments, the issue turned out to be that jQuery wasn't included on the page, so $ wasn't defined. In general, make sure to check the devtools console for error messages and use the ...

View answer
Query Entries only with postDate last of month
2 votes

You can use the LAST_DAY function if you're working with MySQL. To only get entries with a postDate on the last day of the month, you can check if LAST_DAY(postDate) is identical with DATE(postDate). {...

View answer
How do I add an import page to Craft CMS
Accepted answer
2 votes

A good place to put interfaces and tools that aren't super expansive or accessed very often is the Utilities section in the backend. Adding new utilities is very simple, you just add a class that ...

View answer
DOM hash url in entry slug
2 votes

This is impossible (not only in Craft, but in general) because the fragment (hash, the part after the #) is only used on the client-side. This is by design, it's part of the spec that the fragment is ...

View answer
Remove duplicate text from query results
Accepted answer
2 votes

You might want to rethink your approach – any solution you build for this will break as soon as someone adds a new category that doesn't exactly match the naming pattern. In general, try to avoid ...

View answer
If a matrix field is set to "Only save blocks to the site they were created in", do the translation options for the sub-fields do anything?
Accepted answer
2 votes

Yes, you are correct. If you disable propagation, the blocks will only be saved for the site they are created in. So translations will never be visible anywhere. In order not to confuse users, I'd set ...

View answer
Contact form not working since Firefox version update
Accepted answer
2 votes

Not sure I have the full picture yet, but as per the comments, the problem appears to be clear: I think I found the issue. Before, I was disabling the form first and then submitting it. That was ...

View answer
DIsplaying Field Label override on front end
Accepted answer
2 votes

It's a bit awkward to get overwritten labels, since they're not available in the same place as the regular field names – not even on the same object. The regular name is a property of the field object ...

View answer
Remove red error lines in VS code for TWIG
Accepted answer
2 votes

It depends on what extension you're using for the Twig syntax highlighting and which language the file is set to use in VS Code. Extensions I use Twig Language 2 – this extension can handle the code ...

View answer
how to write db-commands on custom table (PHP syntax) inside twig file?
Accepted answer
2 votes

You can't put PHP code into Twig, and there's no straightforward way to write custom DB queries in Twig. That's by design – Twig is a templating language, not meant for custom queries or processing. ...

View answer
Is there a query field?
Accepted answer
2 votes

There's no pre-built field in the core for this, and I don't know of any plugin that provides something like this. However, you can build your own pretty easily! For example, let's say you want a ...

View answer
PHP Parse Error During Installation
Accepted answer
2 votes

The error message tells you that PHP encountered a syntax error while parsing the file Installer.php. Here's the line in question: private function _path(string $vendorDir, string $cwd, string $path): ...

View answer
Replace asterisk (*) with my own HTML in twig-templates
Accepted answer
2 votes

There are several possibilites to solve this. The fastest, as you said, is a regular expression, but those always come with limitations and potential performance issues. You can make this very simple ...

View answer
Set parent-child relationship in PHP
Accepted answer
2 votes

Just to clear up a potential source of confusion: For Craft, the only 'real' parent-child relationships are the hierarchies in Structures (a type of Section). Entry fields and by extension relations (...

View answer
user session for Multi Site
Accepted answer
2 votes

If both sites share a common root domain, you can share cookies by using that root domain as the cookie domain for both sites. This way, a login stored in the cookie for one site will also apply to ...

View answer
Make page urls correspond to their structure
Accepted answer
2 votes

As mentioned in the comments: {parent.uri}/{slug} is the simplest way to do this. This is basically like a recursive function: Top level pages habe no parent, so their URL is just the slug. Second ...

View answer
Show matrix fields based on quantity [Sprig]
Accepted answer
2 votes

The problem that you expect your qty variable to be an array of guests and initialize it like that, but once you set a quantity it will be an integer, so the loop won't work correctly. See this line: {...

View answer
Unable to find the template
Accepted answer
2 votes

You need to define the template root (password-global) in your main module file. This is a gotcha when working on site-specific modules instead of plugins – plugins get a template root based on their ...

View answer
Pass parameters to element query as array - in PHP
2 votes

The Element::find() method does not take any parameters, it just serves as the factory method for the appropriate element query for the given element type (for example, Entry::find() returns an ...

View answer
start ordered list with number 2
2 votes

You can use the start attribute to control the start number of an ordered list: <ol start="2"> <li>Item 1</li> <li>Item 2</li> </ol> Depending on ...

View answer
Generating srcset in a similar way to WordPress
2 votes

You can write a function, a utility template or a macro to make repetitive tasks like generating responsive images easier. I usually prefer templates, because they're easy to extend and they can take ...

View answer
Running a background job in a controller
Accepted answer
2 votes

Class 'modules\importGeoJson\BaseJob' not found You're getting this error because you're trying to extend the craft\queue\BaseJob, but you're not importing (aliasing) that class. In general, a simple ...

View answer
Search query for assets
Accepted answer
2 votes

You can use craft.assets() to search for assets, the same way you can use craft.entries() to find entries. See Querying Assets for details. Asset queries allow you to use mostly the same methods that ...

View answer
Craft's case-insensitive routing
Accepted answer
2 votes

In most cases, case-sensitivity depends on the database collation. By default, Craft uses case insensitive collations (utf8_general_ci or utf8mb4_0900_ai_ci, depending on the charset). You can change ...

View answer
How to exclude Super Table rows matching given entry
Accepted answer
2 votes

Where did you get this id NOT 874 syntax? I don't think that's supported. Entry fields already allow you to serach for related entries by ID, so one of those should work: {% set myMoviesExceptJaws = ...

View answer