How to create custom sorting for a collection list?

I have a collection of Essays. I don’t want to display them as an alphabetical list, not a date created list, not any kind of criteria except my own random choice. Can this be done please?

Z


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

hi @ZeroZero1 the term ‘my random choice’ seems non technical and unfamiliar to me. Nonetheless, there’s an option to include an additional text field in your collection items to serve as an identifier. Once this field is added as an option to the item, you can assign a number to the collection item of your choosing.

Once a collection item has a number assigned to it, you can utilize the WF sorting option, using the special field (number) as an argument. It’s important to note that you should avoid having identical numbers to ensure the collection list displays correctly. Therefore, when you change or add a number, you need to be mindful of this.

EDIT: Another option is to incorporate a switch element. Include a switch named, for instance, active in the item template. Then, activate the ‘active’ switch for the items you wish to display and filter (show) only those with ‘active’ enabled." :man_shrugging:

Two tips on Stan’s solution-
Use a numeric field in your collection.
Make it required so that you’re consistent about populating it ( nulls sort above non-nulls )
Gap your sequence, e.g. 10 20 30, so that it’s easier to insert items later.

You can also use decimal places, but that’s better for a programmatic solution.

1 Like

What is the benefit for using numeric field in this case. I’m genuinely interested as I do not see any difference between “number” vs “string” in this case. Can you more reasoning about this as JS works with “number” and “strings” interchangeably (except calculations)? Is WF filer works better with numbers?

EDIT: I have run short test just in case and result is:

I’m thinking about this extra field for sorting as ID that is always a “string” :man_shrugging:

Thank you all for the input. Although I could once code pretty good in HTML. Javascript and others, I have not developed for a while and gthe language has changed. I am just understanding the idea of a collection. I think I can understand a Collection as a database. This is comprised of:
A Collection wrapper - which I think must be some kind of div block or container

A ollection List - which I think are the declared fields in the database (carious types)

The Collection List Item - I believe this to be a filter hard copy of whatever fields you wish to display on a webpage at a specific location - using elements like Heading, Paraphraph, Image etc. Am I right?

What I need to do is display items such as essays, in an order of my own choosing, in various ways on different parts of my site. I have an option list classing the items but within this, I want to be able to “drag around” (or otherwise move), the Essay items, not by date or Alphabetical order, but according to whim.
A number associated with each item would still give some kind of fixed order I think? SO if I have two different lists of teh same data, then they owudl have to be the same?
I have seen filter options in the RHS panel, but again tehy are not custom.

Thanks for the input. Will mess arounmd, have to go for dirre

Z

you will choose what essay will have specific number - this is your choice

I’m struggling to grasp your intention. Are you suggesting that you’d like to showcase the same essays in various locations but with different arrangements?

Since I’m not entirely clear on your objective, perhaps considering categorizing the essays as collections and assigning each essay to one or more categories could help. You could then utilize IDs or switches as secondary filters.

There are numerous approaches to consider. I advise taking a moment to outline your logic on paper before diving into implementation.

I will also recommend to dive into WF documentation and tutorials to figure out WF options if you will be able to achieve your goals.

Best of luck!

As far as I know, Webflow’s collection list sorting is handled server side, likely in the db query, so numeric and string fields sort differently. If it were a string field, you’d see a sort order like 1, 11, 2, 21.

There might be a way around this, but I’ve found that the string sort has limited use in general because it groups lowercase and uppercase characters separately. apple banana, pear, Avodcado, Orange. I haven’t played much with setting the site locale to see if this changes things.

In some Webflow projects I’ve needed a separate all-lowercase “sortable title” field, and automation to update it.

Hmm, there may be an issue how WF deal with sorting lowercase/capitalise strings but numbers strings are sorted correctly with basic sort function.

When you query from SQL you can “massage” returned data before are passed to client or “massage” these data on client as we are not dealing with Big-O (I mean not a huge amount of data that can be easily sorted on client without performance issues ).

Anyway good to talk :wink:

1 Like

Thank you for your considered replies.
I am looking into it still I have a very basic test project. I have created a Collection and within in a number of fields, invcluding an Options field labelled Essay Type. This has five categories: Humanism Related, Creative Piano, Harmony, Creative Writings and Other. I have also created a number field.
So what I want to do is have different pages for each of these essay types. Each Page would have a blog like template and would be styled - not all fields shown. It would draw Data from my “Essays” Collection.
As an example. On the Creative Piano Page, I might have 10 Essays. I want to list items in the order I choose. There would be an Essay Name, a Summary, a Date,

As some of my writings would be long (50+ pages), I think it would probably be best to offer a PDF format document, with a “download” and “open link in new window” field - or some kind of equivalent function. I am not sure how to upload the PDFs, I could put them on One Drive.
Some Essays could be featured in more than one place, but I think this is trivial as it would amount to a hyperlink. I think using a rich text field is probably (not sure) not wise, for essays that might be long.
I am also contemplating how to handle references

Thank you for your wise advice. Sorry to be tardy, babysitting.

https://preview.webflow.com/preview/apeselephantsandrooms1-6f4b56?utm_medium=preview_link&utm_source=designer&utm_content=apeselephantsandrooms1-6f4b56&preview=6753df56a9a9d1d5e157eac5dbf035d5&workflow=preview

Z

This means you will create page that will include one collection. For each collection will be one page.

Correct when you create page with collection the “template is created automatically so you can set link to **current” post (article)

these are only field you can organise their order and position as you wish.

Do you mean A4 pages that has standard approx 1,800 characters, right? So you can create TOC (search internet or forum on how to in WF) that visitors can easily jump to sections of your romain and PDF offer as option to download as no one would like to download file be able to read website content.

Anyway good luck with your project. :slight_smile:

1 Like

Thank you.

FYI: I meant circa 40= 50 (A4) pages per post. So it’s an Essay title, perhaps date, summary - a paragraph or two, then a “read on” PDF. I have seen a webpage with a click which opens a PDF in my Browser on new tab, often with handy download buttons.

Z

FYI Yes I will use TOCs when the article gets long. Probably within the PDFs. Maybe it’s a good idea to also have the TOC on the same page as the Title and Summary. Could be good for precis.

I am working this up now…

Best wishes
Z

That is the standard but how you would like to implement it is not good for UX. I’m using this approach (preview PDF) eg. in ul where in middle of sentence is a link to document that can be read as eg. financial report from last year etc.

What this means that main article content is still there. With you approach you may face issues with SEO as having only excerpt and rest in PDF Google will have no idea what your website is about as crawlers get minimum information. Anyway, good luck as this is only my opinion.

m2c