MoritzLost
  • Member for 10 months
  • Last seen this week
Is it possible to duplicate an entry as not enabled/live from the listing page?
1 votes

Using duplicateOf is not sufficient to detect duplicates. A draft, provisional draft or revision being applied to the live entry will also have a duplicateOf property, so this will result in live ...

View answer
Field dropdown - default value is not working in CMS
1 votes

The default value will only apply to newly created entries. Existing entries won't have any saved value for this field. You're only seeing the first value as selected in your entry edit screen because ...

View answer
Delete Parent and Children via the frontend
1 votes

Many of those advanced endpoints are undocumented, but you can find out a lot with the devtools. If you use the Delete (with Descendants) option in the backend and check the devtools, you can see it ...

View answer
Given a global, how to get a particular language's version of it?
Accepted answer
1 votes

I'd rethink that approach – if your users want to see the site in French, why are they seeing the site in English? And if they're viewing the English site, does it make sense to show an isolated piece ...

View answer
@webroot - how to find out path?
1 votes

You should specify the @webroot alias in your config/general.php. To make sure the path is always absolute and always correct for each environment, you can use the PHP function dirname() with the ...

View answer
How can I see what fields changed on EVENT_BOEFORE_SAVE and or EVENT_AFTER_SAVE
Accepted answer
1 votes

You can use Element::getDirtyFields() and Element::getDirtyAttributes() to find which custom fields and which attributes (like authorId, postDate, etc) are marked as dirty (modified). Event::on( ...

View answer
How to make "Wheel Form" fields in JSON format using API
1 votes

You need to write a Twig template for the form and add it somewhere on your site. You can either add the form to an existing page or add a custom route for it. See the Wheel Form plugin documentation ...

View answer
Set Session variable inside php controller
Accepted answer
1 votes

The Yii2 components behave a bit like singletons, you shouldn't create new ones manually. Instead, accessing them over the Craft::$app property is preferred, as you indicated. This should work: $...

View answer
Composer error while upgrading from Craft CMS 3.5.8 to 3.7.21
1 votes

Your composer.json indicates that the laravel/homestead package couldn't be found. This is strange, as the package does exist, even though you're requiring a heavily outdated version. Anyway, you can ...

View answer
Updating to 3.7.19 query
Accepted answer
1 votes

Running the query is not required – you can tell that by the version number. Craft doesn't use strict semantic versioning, but backwards incompatible changes are reserved for minor updates (a change ...

View answer
Using 'or' within query parameters
Accepted answer
1 votes

I had this exact same problem a while ago (calender view with a start date and an optional end date). I looked into how to combine multiple field filters with an OR-operator – as far as I can tell, it'...

View answer
Check for existing jobs in queue
1 votes

Yes, you can access the queue component using \Craft::$app->getQueue(). Keep in mind that this may return null or a non-compatible component depending on configuration, so make sure to check if the ...

View answer
How to get multiple image array using API or PHP query
1 votes

Edit: Previous answer was incorrect, see update below. What kind of field is infographics? How is it related to the infographicsImage field you're accessing in the loop? Either way, one of those is ...

View answer
Discord Link dead?
1 votes

The link is correct, it works fine here: Make sure that the domain is not blocked on the network level and there isn't anything weird going on with your DNS settings. Maybe clear your browser cache ...

View answer
Customizing Field Layout / UI element in Craft Control Panel
Accepted answer
1 votes

The template will be rendered with an element variable which you can use to display fields and other properties of the given element. See the info displayed in the settings once you add it to the ...

View answer
How to show all files from a subfolder in craft Backend
1 votes

You can query for assets by using the craft.assets() query factory, see the documentation on Querying Assets for details. There are a couple of ways to narrow down a query. If the folder you mentioned ...

View answer
Get entries which are not related in to another section
1 votes

If the relation is (a) confined to a single field in sectionA and (b) that field can only relate to sectionB entries, you can just query for entries without a relation in that field using the :empty: ...

View answer
What's the attribute of a Matrix field to add error message
Accepted answer
1 votes

Matrix blocks are elements themselves, so the individual fields of a matrix block aren't available as properties on the entry. In the entry save hook, the only thing you can add errors to (that will ...

View answer
Composer Unexpected end of file on new plugin
Accepted answer
1 votes

The error likely indicates some language construct or syntax that is valid in PHP 7.4 but isn't in 7.2 – for example, indented heredoc strings only work in PHP 7.3 and above and would produce the ...

View answer
Settings for redactor's plugin Special characters
1 votes

As per the documentation, you can store your own plugins in the directory /config/redactor/plugins/. It isn't specifically mentioned, but plugins stored in the config directory take precedence before ...

View answer
Manipulating search event
1 votes

There are some errors in your code – maybe those just snuck in when you posted the code here, but right now the hook can't work correctly: $elementQuery is undefined – did you mean $event->...

View answer
What's the best practice for creating computed (dynamic/virtual) attributes on entries?
1 votes

You can use behaviors to add new methods to system components. See the link above for documentation. A behavior is a class that extends yii\base\Behavior and is attached to a component using the ...

View answer
CP Module: saving, editing, and reading a form
Accepted answer
1 votes

Where do you want to store your data? Looks like you're trying to create a settings form for a module? Your trouble probably comes from trying to build a module like you would a plugin. Plugin ...

View answer
Newbie: Migrating Craft website to new host questions
1 votes

First of, Craft is very different from WordPress. With WordPress you can build a site without writing a single line of code using prebuilt themes and plugins, so it's easier to answer questions like ...

View answer
Default field on any single pages
Accepted answer
1 votes

Frame Challenge – The question implies that you're allowing admin changes in production and/or are giving your editors / non-technical-collaborators admin privileges to create new sections, which is a ...

View answer
How to update a User's Entries custom field only once just after save?
Accepted answer
1 votes

Update 2021-09-24 The actual issue is that entries fields can't hold references to drafts only, only to 'real' entries. Drafts have their own ID, but they aren't real entries. The entries field ...

View answer
How to display controller response on twig template?
Accepted answer
1 votes

Your controller looks ok, though I would clean it up a bit and use more expressive variable names to reduce the surface area for bugs: $templateVariables = [ 'status' => true, 'message' =&...

View answer
Optimize relatedTo query
1 votes

Are the nutrition entries associated with restaurant entries through a single field or multiple fields? If it's only one field and you only want to query for restaurants that have any nutrition ...

View answer
Blog pages returning HTTP 404 – Not Found – yii\web\NotFoundHttpException Template not found: blog/_entry
1 votes

For development in general, when something isn't working it's important to look at the output and errors you're getting in order to figure out what's going wrong. In most cases, the error message will ...

View answer
Multiple login forms
Accepted answer
1 votes

You can either use the same form or two different forms with separate URLs. Craft doesn't really care where your login form submission comes from, it's handed off to the same controller regardless. ...

View answer