Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [query]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers
39 views

Return all orders from a list of countries in Commerce v3

A little stuck on trying to get the query right for this, I have a module where I need to write a function that returns all orders placed with billing addresses in a selected list of countries. The ...
cherrykoda's user avatar
  • 1,114
1 vote
1 answer
38 views

Relations query with OR: Find entries based on (lightswitch = false AND relatedTo()) OR (lightswitch = true) / nested relatedTo?

I have the following challenge: we have a news channel for multiple company locations. Some news should be visible globally (for all locations), but some news are only visible for location X. But ...
m_andrasch's user avatar
2 votes
1 answer
60 views

Wildcard searching for custom field queries

I've noticed that the * wildcard works for simple custom field queries, for example if I have three entries named Foo, Foo*, Foo*Bar, running craft.entries.title('Foo*').all() will get 3 results, and ...
gioppe's user avatar
  • 414
1 vote
2 answers
68 views

Cleaning up twig query with nested and/or where

I have troubles understanding the nested twig query syntax. It works fine in PHP code but somehow when using twig I never seem to get it right. This is my raw, dirty query which I want to clean up a ...
bartpulse's user avatar
0 votes
0 answers
37 views

Prioritising Paid Authors In Entry Queries - Craft 4

I have a Craft CMS 4 website with an entry query that's displaying results in order of priority (1, 2, 3 or 4) and sub priority (1, 2 or 3). I've assigned these numbers to the entries via entry fields....
George Bleasdale's user avatar
0 votes
0 answers
25 views

Query user by code and id parameters found in set password path OR custom reset password path

Is there any way to query users using the parameters of set password URLs? I need to distinguish between the very first activation (welcome) email and reset password email because their corresponding ...
biko's user avatar
  • 670
1 vote
1 answer
106 views

Do cache queries work on relation fields and global sets?

I see in the docs I can do something like: {% set entries = craft.entries .sectionId(2) .with(['someRelationField']) .cache(0) .all() %} and this will cache the query indefinitely because of ...
Ryan's user avatar
  • 1,952
0 votes
0 answers
22 views

GET Checkbox Value to the Query (Entries Field) [duplicate]

I am writing my first post because I am stuck and cannot move forward. I need a filter that filters by "Entries Field." The selection is done through a form + checkbox. I also get the ID of ...
Tomka84's user avatar
1 vote
1 answer
291 views

How query all folders of a volume?

I want to query a list of all folders in a specific volume in my front-end template (loggedin users only). I'll need the folderId to display all files of the selected folder. The idea is to show a ...
Maarten Heideman's user avatar
1 vote
0 answers
32 views

Get query of autoinjection in case the entry is not found

Is there a way to get the element query which is/was executed by Craft to autoinject the corresponding entry into the template? (even if it fails) I would like to catch it in case of a 404 to return a ...
Matthias Redl-Mann's user avatar
0 votes
0 answers
71 views

How to join sections in craft entry query

I want to join sections foo and bar in a craft entry query. Where foo.id = bar.title. How do I query all records in one go in style like craft.entries.section...?
tenshi's user avatar
  • 101
0 votes
1 answer
115 views

Get entries where tag = value

Let's say I have a tag group with handle genre. I can make an entry contain information about this tag by creating a field of type tag that uses this group. So I would have a field with handle ...
Álvaro Franz's user avatar
1 vote
1 answer
23 views

Entry query on field using the `and` parameter

I'm struggling to get a and entry query to work - it seems to be stuck on or. Query is {% set blogQ = blogQ.blogTags(['and', blogTag|join(",")]) %} where blogTag is [2291,2290] in this case. ...
Jaytrix's user avatar
  • 337
1 vote
0 answers
29 views

Craft 2 White Screen - All Queries Not Running

I have a CraftCMS 2 template with a JavaScript setTimeout for auto refresh, and quite randomly, the page will only display a white page. Dev mode is enabled, and, through the browser's inspector, in ...
buck1112's user avatar
  • 400
1 vote
1 answer
765 views

Get entries with a specific post date

I'm having absolute brain fog right now. I'm trying to show a list of entries with a given postDate {% set startDate = startDate ?? now|date('Y-m-d') %} craft.entries .section(['jobs', '...
Steven Grant's user avatar
  • 1,855
1 vote
1 answer
100 views

Returning Metadata Fields with GraphQL?

I'm trying to pull as much information from the CMS as possible via the GraphQL API. I can't seem to find any info about how to extract the metadata information for the various entries in the CMS. At ...
Ailish's user avatar
  • 21
3 votes
1 answer
384 views

How to get column name of an entrie's field

I want to query some entries in a section. I am able to write a query using a GET Param as a filter on the title field. If I want to query a custom field however I need to know the precise column ...
Aram Loosman's user avatar
2 votes
2 answers
1k views

Element query for specific fields

Can a return schema be specified for entry queries? I'd only like the titles instead of the whole entry.
ponies's user avatar
  • 387
0 votes
0 answers
868 views

Maximum Response Size in GraphQL API?

hoping someone can point me in the right direction here. I'm trying to query my client's API with the Graphiql interface. My use case requires me to extract quite a lot of data from their system but ...
Ailish's user avatar
  • 21
1 vote
1 answer
294 views

Runtime Object type "Element" is not a possible type for "MyGraphqlInterface" for custom gql resolver/interface

So, I'm probably taking the wrong approach here, but I am attempting to write a custom graphQL query interface, resolver, DB and graphQL query classes in order to return values from a custom Plugin ...
Eric's user avatar
  • 133
1 vote
2 answers
312 views

Cannot pass where Params to query with Twig variable

I have a text field that has three values on new lines. E01001667 E01001668 E01000779 I want to use these for a query that looks like this: {% set mylsoas = craft.entries. section('imdData') ....
joomkit's user avatar
  • 2,024
1 vote
1 answer
278 views

How do I get custom fields of User on graphQL?

I am wanting to fetch queries for custom fields of users, how would I go about doing that? So if I did something like this: query { users { id firstName lastName email photo { ...
Keatyn Garton's user avatar
2 votes
1 answer
694 views

Exclude 2 entries from a query

I know this question has been asked before but I'm still not able to solve the issue in this particular situation. I want to remove one fixed(#95) entry id and the current entry.id from the query. {% ...
Robbie Post's user avatar
1 vote
1 answer
43 views

Events with Speaker: Categories or Channel

Sorry for this general question, i am building a large archive site with many (>1000) Events. Every Event has one or more Speaker. At the moment I am using two channels: "events" and &...
buckdanny's user avatar
  • 207
1 vote
1 answer
64 views

Find First Entry That Matches Current Category

I need help. I am creating a category listing which I have working great. The next step is where I'm struggling a bit as I can't seem to query the related entries on a loop basis. For each "...
Ben's user avatar
  • 45
1 vote
2 answers
777 views

Split a list of entries in two parts

How do I split a list of 10 entries into two parts - one part with 4 entries, followed by an image section, and then the second part with 6 entries. Thanks for your help. markus
Markus Busch's user avatar
3 votes
1 answer
205 views

Using 'or' within query parameters

I have an entry which shows related events, based on the entry category, at the bottom. These events all have a start date and an end date - the end date is required, if the event is only one day, ...
Grace's user avatar
  • 55
1 vote
1 answer
131 views

Remove duplicate text from query results

I have written a query to select all categories for a certain entry. In this case, the category is called "Key Stage" and each one is written "Key Stage 1", "Key Stage 2" ...
Grace's user avatar
  • 55
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
1 vote
2 answers
388 views

Pass parameters to element query as array - in PHP

In Twig, we can do this like this: craft.entries({ id: 11, relatedTo: 22, }) But in PHP code, this does not work: \craft\elements\Entry::find( [ 'id' => 11, ...
Piotr Pogorzelski's user avatar
0 votes
1 answer
175 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.4k
1 vote
0 answers
151 views

Order element query by number of related categories

I'm building an entry template that displays related entries to the current entry. To be related, an entry needs to be the same type as the current entry and share at least one category in one of two ...
MoritzLost's user avatar
  • 11.4k
1 vote
1 answer
125 views

Get raw/unformatted field values?

Is there a way to get raw/unformatted values for a field before they're passed to the field's normalizeValue function? That is, get the value close to how it's stored in the database? I haven't found ...
MoritzLost's user avatar
  • 11.4k
0 votes
0 answers
73 views

how to retrieve any/all related entries?

I have list of banks(institutions) that each one has branches. I'm using GraphQL API. By the bellow code I can get the branches with associated bank(institutions): query branches { entries(limit: ...
Nasser Ali Karimi's user avatar
1 vote
0 answers
46 views

GraphQL API query to load all related data

How to write a query to load entries with its category or any other related data. For example I have cars that related to the BMW category. How I can access the category data in the query that fetch ...
Nasser Ali Karimi's user avatar
3 votes
1 answer
582 views

'and' & 'or' in the same entry query

I've been attempting to create an entry query that queries the same custom field twice. Basically I want to check if a custom field is between 2 numbers OR if it is empty. Currently I'm using this to ...
Mark Lloyd's user avatar
1 vote
1 answer
215 views

Query Entry where number field is conditional to value

I am trying to get entries where a specific number field is bigger than the given value. But Craft is giving me the following response: Am i missing something or is this not supported for number ...
Leonardo's user avatar
  • 471
1 vote
1 answer
516 views

Entry query returns all fields with NULL

When trying to query a specific single entry in a section I get back a result but all the fields inside that result are nulled. This {% set kundenmeinungen = craft.entries.section('unterseiten').slug('...
Kris's user avatar
  • 23
1 vote
1 answer
861 views

Element API: Get Entries Related to Category with Query Parameter

I'm using the Element API Plugin to create an API, with which I want to get entries related to one category, but dynamically with the category set in the Url. What I have so far in the config/element-...
Malte's user avatar
  • 215
2 votes
1 answer
21 views

Search Filters Results Unexpectedly

This question is related to: SuperTable Returning Unexpected Results w/ Template, which is still unresolved. In essence, Im trying to return the results of a Supertable at two different points in my ...
Document Services's user avatar
2 votes
1 answer
116 views

How to structure data: Solo Events (Lectures) and Group of Events (Conferences)

I am working on my first craft project and am wondering how to create the following data structure: I have a page with a large archive of solo-events (lectures, discussions etc). I think I will use a ...
buckdanny's user avatar
  • 207
1 vote
1 answer
601 views

Sprig - Filter entries by custom field checkbox values, separate values as well as all values

I am having a question regarding Sprig. I do want to filter my entries for values that are defined in a dropdown field (example below is simplified). It does work to the point where I want to filter ...
HendrikEng's user avatar
  • 1,064
2 votes
1 answer
35 views

Query entries posted in the past month

I’m trying to show only entries for the created in the last month. I’ve taken this from the example in the docs but it ends up showing nothing. There’s 100% entries with a postDate in the last month. ...
supazu's user avatar
  • 526
0 votes
0 answers
34 views

Hiding enclosing div if all matrix block fields are empty (although they do exist because of another language)

I have an entry with matrix fields. If I add blocks in the main language, but its fields only contain data in one language, the block query (the for loop) still finds these empty fields since they do ...
Matthias's user avatar
  • 110
2 votes
1 answer
483 views

Multiple relatedTo conditions using a combination of "and" and "or"

We're trying to make a filter that allows you to pick multiple items from 1 category, and multiple items from another category and return back all appropriate elements. We're in PHP land not twig so ...
owenmelbz's user avatar
  • 149
1 vote
1 answer
444 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
24 views

Order entries by DATEDIFF

I'm trying to order the results of an entries query by the difference between two date fields but I can't seem to get it to work. Here is my query: {% set todaysStreamsParams = { section : 'films', ...
Document Services's user avatar
1 vote
1 answer
114 views

Eager load commerce order data in custom ElementExporter for Users

I have a custom ElementExporter for users and I'd like to include commerce order data. The below code works, but it's a ton of queries. I don't have a ton of experience with SQL queries, how can this ...
Simon Kuran's user avatar
  • 3,015
1 vote
1 answer
178 views

Is there a way to query for a list of values belonging to a specific field in a queryset?

For instance, if I wanted an array of all the titles belonging to a subset of entries that I wish to query. The way I know how to do this currently is like so: {% set titleList = [] %} {% ...
Brimby's user avatar
  • 343
1 vote
1 answer
8k views

GraphQL query entries by DateTime field between two dates

I am trying to query entries in GraphQL by custom DateTime field value. It works with the base String value like ">=2020-10-01", However querying between two dates like "['and', '>...
Alex89's user avatar
  • 183