Questions tagged [ordering]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
23 views

GraphQL query orderBy number including null

I am attempting to query entries via that have a field (ex numberField) with field type Number. Some of the entries don't have a value for this field, so in the response it has null. I am wanting to ...
user avatar
  • 1
0 votes
0 answers
32 views

Order related entries by the amount they have in common

I am trying to build a function that creates a list of related entries based on a few criteria. This is no issue since this can be easily achieved by using relatedTo. The problem I am facing is, I can'...
user avatar
  • 73
1 vote
2 answers
41 views

OrderBy section when selecting multiple sections in entries query

When getting pages from multiple sections like so: {% set aboutNavigation = craft.entries .section(['about', 'newsIndex']) .all() %} How can I set order that the sections appear? So I want ...
user avatar
  • 1,834
1 vote
0 answers
54 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 ...
user avatar
  • 6,785
0 votes
0 answers
49 views

Multiple structures sharing the same entries?

I'm working on a site that currently has one structure ("projects") that organizes my entries for each specific project. In the admin I can reorder these entries manually... so far so good! ...
user avatar
1 vote
1 answer
14 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', ...
user avatar
1 vote
2 answers
28 views

Getting an zero index and count for an entry list

I currently have an entries field which outputs a list of related entries on page. I'm trying to find a way to display two values for these entries. The first would be a zero index. I'm trying to ...
user avatar
  • 245
1 vote
1 answer
317 views

orderBy title, but remove the word "The" from titles

If I have a huge list of TV shows and Movies, many of them have "The" in the title, meaning they all get grouped together if you order by title. Is it possible to "filter out" a ...
user avatar
  • 85
4 votes
1 answer
694 views

How to order or filter entries by their author's custom field?

Is it possible to order and/or filter all entries from a section whose author has a custom field value that is set to "X"? Below is the starting code. in Twig: {% set elementQuery = craft.entries()...
user avatar
  • 6,326
1 vote
1 answer
140 views

How to order Sites

We have 38 sites running, divided over 6 groups. But for some weird reason on showing the sites list, 10 sites are showing up random. How can we fix this, or how can we order the sites on 'name' or '...
user avatar
1 vote
1 answer
93 views

Sortable Categories on per Entry basis

I've been searching all over for this and have been coming up short unfortunately. Does anyone know if it's possible with in Craft CMS 3 to allow custom sorting of categories on a per entry basis? ...
user avatar
1 vote
1 answer
639 views

Order entries by a category field alphabetically then paginate

I've tried so many different things and can't get this to work... {% set makeCat = craft.categories() .group('make') .orderBy('title') .limit(21) %} {% paginate makeCat as pageInfo, ...
user avatar
1 vote
1 answer
241 views

Ignoring "The " and "A " when sorting entries

I have this code which used to work with 2.x versions: {% set foobars = craft.entries({ section: "foobars"}).order("(CASE WHEN title LIKE 'The %' THEN SUBSTRING(title, 5) WHEN title LIKE 'A %' THEN ...
user avatar
  • 111
1 vote
1 answer
58 views

Grouping entries and ordering by section

Im grabbing entries from two sections and displaying them using the group filter. {% set entries = craft.entries().section('extendedEvents, festivalEvents')%} {% set allEvents = entries %} {% set ...
user avatar
  • 33
2 votes
1 answer
1k views

Order entries by custom date and time fields

I have an events channel where each entry has three custom date/time fields: startDate (Date Only) startTime (Time Only) endTime (Time Only) I was originally using this code to set my entries, but ...
user avatar
  • 960
1 vote
1 answer
213 views

How to create ordered list of categories from multiple category groups

I have got multiple category groups and I need to concatenate them into one list for a filter UI element. At the moment I have the following: {% set categories = craft.categories.group('colour').all(...
user avatar
  • 1,032
2 votes
1 answer
135 views

Set OrderBy on Grouped Query Involving Smart Map Field

I'm working with a Structure of resort locations. Each resort has a field address which is a Smart Map field. I'm trying to create an initial display page that groups the resorts based on their state (...
user avatar
  • 1,022
2 votes
0 answers
358 views

Order entries by custom date field

I want to modify this query so that the dated entries are sorted in descending order on a custom field called 'startDate'. Have tried adding .order('startDate') to the end of the craft.entries(query)....
user avatar
1 vote
1 answer
157 views

Advanced sorting of events with database expressions (Solspace Calendar)

I want to do some complicated sorting of events coming back from the Solspace Calendar plugin. I'm not certain whether this issue is specific to this plugin or whether it's a general Craft thing. In ...
user avatar
  • 165
1 vote
0 answers
90 views

How to sort entries of a timeline?

I am building a timeline which I want to paginate. For this to be efficient, the timeline entries should be in a linear order. The challenge is that entries before present (BP) have to be in ...
user avatar
1 vote
1 answer
77 views

SQL error when trying to use sortOrder on Matrix related block (Craft 2)

I'm getting the following SQL error when trying to simply order related entries in a Matrix block. Anyway around this? CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity ...
user avatar
0 votes
1 answer
140 views

How do I send PayPal the Craft Commerce Order Number?

The client is using PayPal Express for the payment gateway. When orders are placed, Paypal shows the ID for the order, not the Order Number. Is there somewhere I can change that?
user avatar
  • 107
1 vote
0 answers
195 views

Order Entries by Category Fields (with fallback)

This is almost a duplicate of this question I have a section which I want to sort by category field. But the categories are not mandatory. When I apply |group('refSorter.first().title') it will ...
user avatar
  • 3,664
1 vote
1 answer
715 views

Placing a Test Order (Craft Commerce)

This is a really basic question but I have had trouble finding an answer, or documentation on it. What is the best way to place a test order with a default Craft Commerce installation? I'm unable to ...
user avatar
  • 45
1 vote
2 answers
366 views

Craft CMS - Dynamic Order Field Layout In Sections

I'm wanting to have the order of my elements within a template dynamic so that the user whilst in a template of page can reorder the modules as they please. See screenshot for example Within the ...
user avatar
  • 153
2 votes
3 answers
92 views

Show time ordered entries from midnight at end of loop

I'm creating a line up listing page for a festival, across 4 nights. Acts are listed, per day, sorted by a date field in order of a start time field. The issue I'm having is that midnight until 3am ...
user avatar
  • 145
1 vote
1 answer
341 views

Sort matrix blocks by date and limit to 10 entries

I'm loading multiple matrix blocks from multiple entries to the homepage if the date is today or in the future. So far this works but now I'm trying to sort the blocks by date and limit the output to ...
user avatar
1 vote
1 answer
168 views

Select query question

I am trying to do the following with craft.entries but I think it may not be possible without a plugin. I have 9 categories with related entries on all of them. I would like to get the latest ...
user avatar
1 vote
1 answer
456 views

Order a paginated entry by postDate

I'm stumped trying to order paginated entries for a channel. The end goal is to have listings with the most recent postDate at the top. The code below has the most recent item third instead of first. ...
user avatar
1 vote
1 answer
1k views

Entries order postDate not working

I'm trying to get prev/next entry using positionedAfter and positionedBefore filters but getting weird order on results because order('postDate desc') seems to be ignored. {% set prevSibling = craft....
user avatar
  • 11
1 vote
0 answers
276 views

Craft Commerce: Sort products by Sale price

Trying to sort products by price. {% set products = craft.commerce.products({ type: 'footwear', limit: shopSettings.productsPerPage, order: 'defaultPrice asc', }) %} It works fine. Please ...
user avatar
  • 83
3 votes
1 answer
375 views

Ordering entries based on an eager-loaded element's custom field

I have a query that loads a set of movies, and eager-loads corresponding shows, which are related elements. For now, the movies are sorted by startingDate, which is a custom field in the movie entry: ...
user avatar
  • 839
1 vote
1 answer
381 views

Sort entry titles alphabetically excluding 'The'?

I need to list the names of all of my entries in alphabetical order excluding 'the' (which could only be at the beginning). I've looked around online, but I was only able to find a code segment (which ...
user avatar
  • 21
1 vote
1 answer
398 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 ...
user avatar
  • 485
1 vote
1 answer
60 views

Disable ordering

I'm attempting to output a list of entries using slug names. When I do the following, the entries are automatically reordered in alphabetical (title) order. Same thing happens if I target the ID's ...
user avatar
  • 2,265
0 votes
1 answer
244 views

How to get latest entries by particular field?

I have 4 fields in my section: -Images -Videos -GIFs -PNGs On my homepage, I have a section where I have to show 5 latest entries of Images, Videos, GIFs & PNGs. How can I do that ? I tried: ...
user avatar
2 votes
1 answer
289 views

Ordering Structure Sections with Structure Handles

I am using the code below to output a group of sections that have entries along with their section handle. How would I order the sections (ideally by structureId)? I'm not opposed to using supersort ...
user avatar
2 votes
2 answers
91 views

Another gallery question

I have looked around but cant find an answer to this. I have a structure for my gallery page, in-which there are three separate entries called A, B and C. There are different images within these ...
user avatar
  • 132
1 vote
2 answers
163 views

Order entries, exclude 'the' from order criteria

I know this is partly a Twig question, but I've poked around quite a bit here, in Twig docs, Craft docs, and cannot find the right syntax. I have a bunch of entries with titles like: Hotel A Grand ...
user avatar
  • 608
1 vote
1 answer
332 views

Ordering/sorting products by their variant stock level

I'm trying to implement a sort order in my product listings so that all of the out of stock products are last. I'm unsure how or if this is possible because the stock is set on the variants of a ...
user avatar
  • 3,833
2 votes
1 answer
909 views

Order/sort a structure section by date too?

Is it possible to have a Structure section ordered by date (desc) as a default and then take the custom ordering in the CP into account?
user avatar
  • 299
1 vote
1 answer
140 views

How can I do nested ordering?

I want to put the index of section in order by two fields: featured and startDate. Basically, I want the featured entries to rise to the top of the index, and then within the featured posts I want ...
user avatar
2 votes
2 answers
444 views

Order entries based on date field in the Control Panel

I have some entries and I want to order them in the Control Panel based on a date field of those entries. Is that possible ?
user avatar
  • 197
2 votes
0 answers
204 views

Sort entries by related entry title

I’m trying to sort entries from a section called exhibitions by startDate and then by the title field of a related gallery entry. So exhibition entries with the same entry.startDate are ordered ...
user avatar
1 vote
1 answer
306 views

Yearly/Monthy archive listing sorted by month

I've got a list of entries grouped by year which is working correctly except that the months are being output in the the reverse order. This code outputs the years in the correct order but the months ...
user avatar
  • 1,907
1 vote
0 answers
108 views

Different order per locale for Structures

I know this is a long shot, but is there a way to order a Structure differently per locale? As in the standard drag and drop ordering that comes with a structure but with the ordering saved for each ...
user avatar
2 votes
2 answers
205 views

How can I order a sections entries by their children entry postDate?

Is it possible to order a section of entries by their child entries post date? {% for article in craft.entries({ section: 'articles', type: 'videoArticle', limit: 6 }).getChildren().order(...
user avatar
  • 227
1 vote
1 answer
254 views

Sorting across blocks (to get prev/next links)

issue is an entry that has a matrix field named contents, whose blocks have an entries field named works, and the related works channel has an entries field named authorPeople. Issue 1's contents ...
user avatar
1 vote
1 answer
429 views

Ordering relatedTo entries

There are a few tickets touching on this, but the solutions proposed aren't working and I'd like to share the use case: I have a Table of Contents page that is outputting a set of entries based on an ...
user avatar
2 votes
1 answer
54 views

Hide users without profile pics

I'm working on a site that has logins for members, but I'd like to have a page that shows all members with a name and picture. To do this, we had to import an existing database that doesn't have a lot ...
user avatar
  • 363