Questions tagged [query]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
3 answers
2k 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). ...
Paloma Martinez's user avatar
2 votes
1 answer
179 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. ...
Danielle Frappier's user avatar
4 votes
1 answer
954 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....
j00lz's user avatar
  • 769
3 votes
1 answer
2k 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 ...
Steven Thate's user avatar
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(...
Rosana Ruiz's user avatar
2 votes
2 answers
619 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()->...
Jeroen's user avatar
  • 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 ...
Vin's user avatar
  • 383
1 vote
1 answer
429 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 ...
Kevon's user avatar
  • 160
1 vote
1 answer
165 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 ...
yu xia's user avatar
  • 397
1 vote
1 answer
83 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 ...
Moucky's user avatar
  • 85
1 vote
1 answer
569 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 ...
hisnameisjimmy's user avatar
0 votes
1 answer
174 views

Find related entries by specific position in the entries field

I'm looking for a way to limit a reverse relations query to only match the first selected entry in an entries field. Some context: I have two entry types, institutes and offers. Offers have an ...
MoritzLost's user avatar
  • 11.2k