New answers tagged

1 vote

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

Thanks for assistance. I was able to solve the problem by creating an asset, got the asset id and added the asset field to the id: $event->sender->assetField = [newassetid];
3 votes
Accepted

How to create pager of elements on CRAFT CMS

You’re looking for the {% paginate %} tag! This will take care of reading the "page" out of your URL, based on the pageTrigger config setting and setting the query’s offset: {# Set up your ...
1 vote

How to make the directory filter work according to the OR principle?

Generally, and as @MoritzLost's answer suggest, using elements (i.e. entries or categories) and the relatedTo param instead of Checkboxes for categorisation, is definitely going to be a better idea in ...
1 vote

How to make the directory filter work according to the OR principle?

For multiple select/checkboxes fields, you can use the search index. {% set games = craft.entries().section('games').search('genreGame:horror OR specialsGame:multiplayer').all() %} Note that you ...
  • 390
4 votes
Accepted

How to make the directory filter work according to the OR principle?

You can use a relatedTo parameter to limit your query to all games that are related to one of multiple elements. This is assuming that both specialsGame and genreGame are entries fields or another ...
  • 7,385
1 vote

Is there any plugin for Blog in Craft 3?

There is now: https://plugins.craftcms.com/blogify?craft4 See out of the box demo here: https://craftcmsplugins.com/blog/index Full disclosure, I'm the author.
  • 390
1 vote
Accepted

Webp not available in image transformations although set up

So, by the looks of it I'm a little dumb and didn't find this article on how to work around that issue. If you have this issue using cPanel this will help you out. Short version: When using EA-PHP, (...
  • 31
2 votes
Accepted

How do I filter items by price?

The documentation for every field type includes examples for sorting and filtering by that field. Here's the documentation for the numbers field which includes examples for this exact scenario. If ...
  • 7,385
2 votes
Accepted

How do I get the number of entries that have checkboxes?

To query on variable field names, you can use object notation; i.e. an object passed to craft.entries(): {% set field = 'genreGames' %} {% set games = craft.entries({ (field): 'action' }).section('...
1 vote

Update Craft 2 to 3?

I found this video more helpful. But yes, you'll need composer is you are going to follow this video https://www.youtube.com/watch?v=i029_DNFsmc&ab_channel=CraftQuest
2 votes

How do I get the number of entries that have checkboxes?

To answer your initial question, I think you could use the attribute function here to solve your problem: {% set field = 'genreGames' %} {{ attribute(games, field, 'action').all()|length }} FYI, ...
2 votes
Accepted

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

This works: UPDATE: As @MatsMikkelRummelhoff has pointed out, Craft's project config will handle the schema for category groups. $defaultSite = Craft::$app->sites->getSiteByHandle('default'); //...
  • 417
1 vote
Accepted

How do I get a list of checkboxes for the item addition form?

If you need to get the options independent of any specific entry, you can use the fields service to get the field and retrieve its options. {% set field = craft.app.fields.getFieldByHandle('...
  • 7,385
1 vote

yii\base\UnknownPropertyException: Setting unknown property: craft\records\Element::canonicalId

Enabling the Sections for the new site seems to have fixed it.
2 votes
Accepted

How to create a filter of products with Craft CMS?

You need to retrieve the parameters from the current request and then apply them to the query. You can get the parameters like this: {% set searchTerm = craft.app.request.getQueryParam('title') %} {% ...
  • 7,385
1 vote

Set preferred language for new users in CP in craft 3

In Craft 3 (and 4), the default language for new users can be set using the defaultCpLanguage config setting. It's also possible to define a default locale using the defaultCpLocale setting (the ...
1 vote
Accepted

If is not triggered by a cron http request. Why?

This probably happens because you're using the .search() param to query for the existing review entry, which means that Craft will look in the search index to try and find an entry matching the review ...

Top 50 recent answers are included