Questions tagged [ordering]
The ordering tag has no usage guidance.
89
questions
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 = {
...
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->...
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 ...
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 ...
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 ...
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!
...
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',
...
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 ...
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 ...
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()...
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 '...
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?
...
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, ...
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 ...
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 ...
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 ...
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(...
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 (...
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)....
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 ...
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 ...
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 ...
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?
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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. ...
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....
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 ...
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:
...
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 ...
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 ...
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 ...
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:
...
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 ...
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 ...
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 ...
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 ...
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?
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 ...
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 ?
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 ...
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 ...
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 ...
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(...
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 ...
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 ...