Questions tagged [query]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
3 answers
923 views

Get array of titles instead of whole collection of entries' attributes

I know that to get the entries I can do: craft.entries.all() but instead of getting the whole collection of entries, I would like to get an array of titles from those entries (or any other field). ...
2 votes
1 answer
174 views

Where to put where() for a query looking for a lightswitch field

Struggling with syntax here. I'm trying to query entries in the "resources" section, ordered by postDate desc, limit 1 and that also has the lightswitch "featured" as true. Here is what I have. ...
4 votes
1 answer
924 views

Optimizing pagespeed

I'm not sure what is the cause for this page rendering so slow. I thought it was the image transforms but I've removed them and still it's really slow to render. Page in question: http://dharmaavenue....
  • 769
3 votes
1 answer
1k views

Query entries between two values

I am trying to query entries (scripts) when a custom expiration date field is within a certain range. These questions/answers helped me get as far as I am, but I'm still stuck: Advanced query/filter ...
3 votes
2 answers
4k views

How to query an entry by a custom field in Craft 3

How do you query an Element by a custom field in Craft 3? My first try, according to craftcms/docs was: $country = Entry::find() ->section('countries') ->where(...
2 votes
2 answers
602 views

Element Query matrixfields where

I'm trying to query entries in a section where the (activities) entry has an item in a matrix field timeSlots -> timeSlot -> startDate. The startDate must be >= NOW(). $query = Entry::find()->...
  • 308
1 vote
1 answer
1k views

Craft query Matrix blocks in twig

Is it possible to query elements of type MatrixBlock in Twig like other elements? You can get entries with {% set entries = craft.entries.all() %} Is there something similar available for Matrix ...
  • 373
1 vote
1 answer
123 views

How to get entries with or

it is possible to do like this: $users = Entry::find() ->userLevel('>3') ->or group('admin') So in database level,the sql will go like this: select * from users where users.userLevel ...
  • 397
1 vote
1 answer
81 views

Optimising search query

I was wondering if there is a better way to do a query like this, it takes a long time to execute and I know setting the parent variable is where there's a problem but am not sure of an alternative ...
  • 85
1 vote
1 answer
546 views

MySQL CPU pegged on specific query

Very similar (almost exact) to this question: Poor performance on midsized site / Queries without index? CPU keeps getting pegged to 100% for MySQL, which makes the admin interface very slow (the ...
1 vote
1 answer
376 views

Craft 3 - Twig search query for entry with custom EntriesField containing disabled entry

I have a search form with 1 simple input (q) I also have 2 sections: SECTION-A & SECTION-B The search is for entries within SECTION A. The entry I'm searching for contains a custom entriesField ...
  • 160