Questions tagged [queries]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
33 views

Duplicate queries out of the box?

I'm trying to strip back duplicated queries on a site, but after removing as much as possible from the homepage so nothing is coming from the CMS I'm still getting 7 duplicate queries. Is it possible ...
Jaytrix's user avatar
  • 187
1 vote
1 answer
22 views

Date of latest (parent) related entry?

I have a few sections whose main purpose is to be related to other entries - think authors' names, so a user can click through to all their entries. On the templates for these pages - as well as tag ...
Emma Swann's user avatar
0 votes
1 answer
86 views

What fields are eager loaded by default in Craft Queries?

I'm testing the DB queries required for a Craft query and I realized that adding the title field to the eager loading doesn't change anything. So it seems like the title is retrieved by default. Means:...
Álvaro Franz's user avatar
0 votes
0 answers
752 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
0 votes
1 answer
35 views

Multiple entries urls performance

I was wondering if there is a more efficient way, performance side, to call multiple urls for a navigation element in case of a multi language site (so static links are not an option). <div> &...
Samuel's user avatar
  • 69
0 votes
0 answers
256 views

Duplicate database queries and timeouts

I'm looking to get some advice on excessively duplicated database queries when selecting single types in Craft CMS Our craft instance keeps timing out when trying to load the home page single entry, ...
Kyle Lambert's user avatar
1 vote
1 answer
95 views

Is there a query field?

In Craft, is there a field that allows the user to create a custom query in the back-end? Something similar to the filters in Wordpress' query loop block? https://wordpress.org/support/article/query-...
Aron15's user avatar
  • 35
0 votes
1 answer
92 views

Improve performance and element queries when used multiple times

So I am building a mega menu and a separate set of templates for mobile. Both use the same set of element queries, which query two larger sections for pages and hierarchy. I am seeing quite slow load ...
Terry Upton's user avatar
  • 1,884
2 votes
1 answer
190 views

Craft Event Date Range in Craft

I'm creating a date range where I only want to show upcoming events in the next 30 days based on a start date. I have created my query but when I add my if statement to filter on the start date it ...
Dan Lee's user avatar
  • 1,107
1 vote
1 answer
377 views

GraphQL: get prev / next entry from current entry (channel)

Is there a way to get the prev and next entry from the current entry, when this entry is inside a channel and not a structure? query ($id: [QueryArgument], $rel: Int) { entry: entry(id: $id) { ...
davidhellmann's user avatar
1 vote
1 answer
43 views

Is this a basic error, or do I misunderstand how Craft queries the database?

I’ve been wrestling with a site from another developer (who will not be named). He seems to have a pretty solid grasp of PHP, and I had assumed that he also understood Craft well. However, as I ...
mitrol's user avatar
  • 252
1 vote
1 answer
71 views

Help with an Entries field to an array I can use elsewhere

I have an Entries field so I can select a number of posts to feature in a "Hero" section on the home page, as well as a "most popular" section underneath it. However, the Hero ...
MarkD's user avatar
  • 85
1 vote
2 answers
121 views

Querying across relationships in a template

I have two Sections on my site: Country and Alert. The Alert section has a relation with Country via an "Entries" field. An Alert represents something that is happening in a particular country for a ...
Timmy O'Mahony's user avatar
1 vote
1 answer
760 views

How to search a matrix block with a specific handle?

I want to query a specific matrix block using text search which will search all the searchable fields in that particular block and give me output in the form of blocks that I can further process. I ...
hvs's user avatar
  • 283
1 vote
3 answers
2k views

Show Entries based on content in a Matrix Field

I have a product with a variant matrix field(productVariants). Inside each variant is the option to supply a sale price (salePrice). On the front end, I'm trying to show a product grid of only ...
FortySeven Media's user avatar
2 votes
0 answers
359 views

Advanced queries with Super Table

I have three channels: Events, stages and artists. An artist is added to a timetable super table field in the stage channel. In the event, I have a stages field where I select stages. Events also ...
Jorge Anzola's user avatar
2 votes
1 answer
47 views

How to show entires from past 12 months?

I need to display entries from the past 12 months. I'd like to create an entry query and set the timeframe of the entries I need.
Jeff Irwin's user avatar
1 vote
2 answers
285 views

Where should the .all() be placed in Craft 3

I'm confused, I have ended up with 2 similar queries in a template after converting them from Craft 2. {% set events = craft.entries() .section('events') .eventDate('>' ~ now|date('Y-m-d H:...
Paul Frost's user avatar
  • 1,048
1 vote
0 answers
35 views

Paginate entries based on related status

So, let's assume I have two channels. events and movies, being events the screening time of each movie. In the admin, in the event entry, you can select one movie. The movie could be disabled. The ...
Jorge Anzola's user avatar
1 vote
1 answer
183 views

Correctly using eager loading in Plugin development

I'm trying to get some data with eager loading, which results in more queries than before. Is there another way to tune down the number of queries as low as possible? As you can see i only need the ...
RvdB's user avatar
  • 80
1 vote
0 answers
70 views

Combine multi-tiered loop into a single query (via plugin)

I am very new to Craft so forgive me if I knacker how this is asked. I have a set of IDs in an array. I try sending that into a relatedTo statement (which yields a series of locations...see below ...
Outside Edge's user avatar
1 vote
1 answer
62 views

Calendar archives architecture

I created a section on a site that shows a two-month calendar. The calendar has links to entries based on a release date. The release dates are created using a date/time filed. (Dates are different ...
Ricardo Henriquez's user avatar
0 votes
0 answers
140 views

Best way to improve complex query?

This question is related to a previous question I asked: Sort entries in a category via entry field I have a page that is running the same query from the previous question: {% set businesses = craft....
Steven Thate's user avatar
1 vote
1 answer
693 views

RelatedTo query with length criteria

I am trying to get results from a relatedTo query, but only if there are more than say 1 results. Right now I am using two queries to achieve this, like so: {% set authors = craft.entries({ ...
Evangelos's user avatar
1 vote
1 answer
289 views

Query multiple fields with dates

So I'm trying to build a query based on events and their start and end dates. Once a user selects a year, I want to display all events that took place in that year, but also display events that might ...
dace's user avatar
  • 241
1 vote
1 answer
407 views

Sort products by category field value

All of my products have a category field called stateCat. These state categories have a field called stateImportance. This is because some states are more important than others and I want to sort the ...
Branko's user avatar
  • 495
1 vote
1 answer
48 views

Query is outputting additional results

I have four select drop downs which let the user filter the results by county, development, price and development status. However, I'm getting results showing in the wrong/multiple categories for ...
mention79's user avatar
  • 543
3 votes
1 answer
170 views

Using relatedTo programatically?

I'm trying to extend the ElementCriteriaModel using the guide here: https://blog.tighten.co/craft-cms-building-complex-queries-by-extending-the-elementcriteriamodel However I need to re-implement ...
amof's user avatar
  • 151
2 votes
1 answer
632 views

How can I use a WHERE statement in my template?

I am trying query against URL segments. Where I am hung up is how to pass those arguments to a related field. For example, here is my current query: twig {% set profiles = craft.entries({ ...
Damon's user avatar
  • 4,706
1 vote
0 answers
165 views

Query category by price

My client has requested to be able to filter the results page by price via a dropdown, which you can see in the attached screenshot. Basically the results page shows a list of around 15 property ...
mention79's user avatar
  • 543
2 votes
1 answer
523 views

Better way to group by category and include full category entry

The basic idea is that I want to group my entries by category, but I want more than just the category title—I need the entire category entry. My previous post alludes to this, but I've since ...
Darren Wood's user avatar
0 votes
1 answer
494 views

Anyone have a createCommand example?

So I am using a plugin to import data and it isn't assigning the values (asset is inside of Matrix) so I am going to modify the plugin and add code to lookup values that I need to assign to ...
Subrato M's user avatar
  • 109
4 votes
2 answers
1k views

Query only returning 100 records at a time?

I am trying to export data from a database to a csv file, I am using the code below to retrieve the data from the DB, but it only returns 100 rows, how can I fix that? $criteria = craft()->...
user2997606's user avatar
2 votes
1 answer
161 views

Is it possible to skip entries with children?

Hi I m using elementapi plugin to create an json object from my elements. I would like to get all entries, but not those ones who have a children. My criteria it looks like this now 'elementType' =&...
Alex's user avatar
  • 143
1 vote
2 answers
105 views

Tag mysteriously not found

Weird issue where a tag was not found using the tags search query. That tag is in the CMS (in news entries) as well as the DB, and even shows up in other queries. Query in question: {% set tag =...
biko's user avatar
  • 660
4 votes
2 answers
714 views

When is the find() method actually necessary?

I've noticed code samples like the following that use the find() method. {% for entry in craft.entries.section('blog').limit(5).find() %} <li><a href="{{ entry.url }}">{{ entry.title }...
Tim Knight's user avatar
  • 1,022
1 vote
1 answer
422 views

Queries in devMode

When I look at the console log when devMode is enabled, I notice there's a lot going on, and I'm not sure if what I'm seeing is normal or not. There are dozens of [trace][system.db.CDbCommand]\...
Paul's user avatar
  • 339
2 votes
1 answer
616 views

How to write query with startdate <= now && enddate >= now?

I'm trying to make a query which has 2 conditions who has to be true both. In PHP I should use && to get this. startdate <= now && enddate >= now. How do I write this in Craft twig? ...
Martijn La Feber's user avatar
0 votes
1 answer
176 views

Freelance work available [duplicate]

I am looking for some support as the developer who built my site (www.lexiconthai.com) is no longer available. I need a few small changes doing right now (adding meta tag plug in, changing fonts), ...
David Norcross's user avatar
0 votes
0 answers
86 views

Advanced search form with checkboxes [duplicate]

So it seems that Matrix fields don't work with the object syntax so I've changed my field structure to use standard dropdowns, checkboxes and a number field. I have the dropdown (gender) and number ...
Rob's user avatar
  • 865
0 votes
1 answer
154 views

craft.request.getQuery returns empty on multi lingual site

I have the strangest bug. I have a site with two languages, Norwegian and English. In my code i check for craft.request.getQuery('prodid'). Locally in Apache this works fine with both language URLs, ...
KnutSv's user avatar
  • 268
3 votes
1 answer
1k views

How do I sort a collection of entries from multiple sections by date?

I want to create a featured story slider on my website and gather the latest entries from multiple channels to populate it. Here is what is working: # fetch the entries {% set featuredBlog = craft....
Amit Erandole's user avatar
2 votes
1 answer
810 views

Using relatedTo, and/or and :empty/:notempty in queries

I got users that has 3 Entries fields in their profile: breadForMonday, breadForWednesday and breadForFriday. I want to differentiate between users with 1, 2 or 3 selected entries. How would I use ...
Fred Carlsen's user avatar
  • 2,997
2 votes
1 answer
318 views

Find Entries with Multiple Matches in a Single Field

I have entries in a channel called "shorts". Each of those entries has a field called "size" that can be a value of small, medium or large. I have created a form where I want users to be able to ...
triplethreat23's user avatar
1 vote
0 answers
286 views

Limit fields in query / Optimize query

What I'm doing is fairly simple: {% cache %} {% set jobs = craft.entries.section('job').find({ order: 'dateCreated asc', limit: 0 }) %} {% for job in jobs %} {{ macros.jobProfile(job) ...
nexflo's user avatar
  • 539
3 votes
2 answers
942 views

Check if Category is in Query

I'm trying to check to see if a particular category (In a loop) exists in a query submitted from a search form. At the moment I'm doing this inside a 'childCategory' loop... {% for childCategory in ...
Jason Mayo's user avatar
0 votes
1 answer
33 views

How do you find more documentation about queries, services, plugins, etc?

So I've been having so much trouble finding adequate examples of how to do things when writing a plugin. How do you find more? (see below for my own answer)
kr37's user avatar
  • 1,335
0 votes
2 answers
2k views

Using Services to get all the Categories related to an Entry?

In a plugin, I've been advised to try to use craft built-in services instead of direct db queries. So can anyone help with this: For an entry type that includes a categories field, how to get all the ...
kr37's user avatar
  • 1,335
1 vote
1 answer
2k views

db query to get fields related to entry

Sorry if this question is starting off too abstract. I'm porting a calendar plugin from Textpattern and WordPress into Craft. Basic workflow for the output has been (in twig terms): {% set start = "...
kr37's user avatar
  • 1,335
4 votes
1 answer
573 views

RelatedTo Query Using Both "and" and "or"

I'm attempting to build a filter that queries entries of a section based on two criteria: A selection of one or more categories (inclusive), and a single related entry (exclusive). Specifically, the ...
Marcus's user avatar
  • 419