Questions tagged [ordering]

The tag has no usage guidance.

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

How to order entries by two fields, one being a date, the other being a time?

I would like to order my entries first by date, and then by time. So if several entries are on the same date, they will be ordered by time within that day. This is my query: {% set query = { ...
outline4's user avatar
  • 595
1 vote
1 answer
76 views

How To Designate Adjuster on Order Only

Registering like so and all is well. Event::on( OrderAdjustments::class, OrderAdjustments::EVENT_REGISTER_ORDER_ADJUSTERS, function(RegisterComponentTypesEvent $event) { $event->...
Steve Mock's user avatar
1 vote
1 answer
379 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 ...
toddhf's user avatar
  • 11
1 vote
2 answers
74 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 ...
Terry Upton's user avatar
  • 1,884
1 vote
0 answers
120 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
  • 10.7k
0 votes
0 answers
57 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! ...
CinemaMike's user avatar
1 vote
1 answer
22 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
2 answers
60 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 ...
Adam's user avatar
  • 255
1 vote
1 answer
540 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 ...
MarkD's user avatar
  • 85
4 votes
1 answer
945 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()...
Ben Croker's user avatar
  • 7,266
1 vote
1 answer
176 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 '...
John Stevens's user avatar
1 vote
1 answer
97 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? ...
Evan Bartlett's user avatar
1 vote
1 answer
799 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, ...
kinetikmedia's user avatar
1 vote
1 answer
281 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 ...
LosHosez's user avatar
  • 111
1 vote
1 answer
116 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 ...
Kevin's 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 ...
artmem's user avatar
  • 1,012
1 vote
1 answer
267 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(...
Jay's user avatar
  • 1,042
2 votes
1 answer
159 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 (...
Tim Knight's user avatar
  • 1,022
2 votes
0 answers
441 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)....
James Greig's user avatar
1 vote
1 answer
180 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 ...
tremby's user avatar
  • 165
1 vote
0 answers
93 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 ...
Crafty Cat's user avatar
1 vote
1 answer
82 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 ...
richardpixel's user avatar
0 votes
1 answer
169 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?
smartpill's user avatar
  • 107
1 vote
0 answers
223 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 ...
KSPR's user avatar
  • 3,776
1 vote
1 answer
755 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 ...
Bryant's user avatar
  • 45
1 vote
2 answers
406 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 ...
Filth's user avatar
  • 153
2 votes
3 answers
105 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 ...
MikeeBee's user avatar
  • 155
1 vote
1 answer
345 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 ...
Christian Lemmers's user avatar
1 vote
1 answer
177 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 ...
Evangelos's user avatar
1 vote
1 answer
484 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. ...
Jon Livingston's user avatar
1 vote
1 answer
2k 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....
Andris's user avatar
  • 11
2 votes
2 answers
358 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 ...
Oleg's user avatar
  • 103
3 votes
1 answer
418 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: ...
KSP's user avatar
  • 849
1 vote
1 answer
417 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 ...
Nick pappas's user avatar
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
77 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 ...
Mark Notton's user avatar
  • 2,315
0 votes
1 answer
301 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: ...
hashtagerrors's user avatar
2 votes
1 answer
345 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 ...
triplethreat23's user avatar
2 votes
2 answers
94 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 ...
Spheriri's user avatar
  • 132
1 vote
2 answers
197 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 ...
4midori's user avatar
  • 626
1 vote
1 answer
368 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 ...
Luke Pearce's user avatar
  • 3,863
2 votes
1 answer
1k 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?
A Herrera's user avatar
  • 309
1 vote
1 answer
169 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 ...
jimchristie's user avatar
2 votes
2 answers
469 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 ?
nickGR's user avatar
  • 197
2 votes
0 answers
226 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 ...
periodical's user avatar
1 vote
1 answer
318 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 ...
CreateSean's user avatar
  • 1,963
1 vote
0 answers
119 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 ...
Clive Portman's user avatar
2 votes
2 answers
219 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(...
postsrc's user avatar
  • 227
1 vote
1 answer
277 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 ...
Mark J. Reeves's user avatar
1 vote
1 answer
450 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 ...
Mark J. Reeves's user avatar