CMS sort not working (+ combine +filter +pagination)

Hello,
I use several solutions on this page

  • CMS Filter
  • CMS Sort
  • CMS Combine
  • CMS Pagination
    Everything seems to work like a charm, except the sorting.
    Any idea what’s causing the problem?

The project link is here: https://preview.webflow.com/preview/seyna-ouiflow?utm_medium=preview_link&utm_source=designer&utm_content=seyna-ouiflow&preview=307c26eda3c4703d4a3630d2c4e4c9ba&pageId=653bdbfac1d2b7e5c6315697&workflow=preview

Thanks for your help

Hey @Fabien_ouiflow! Can we switch the select element to a button and then add this code to the </body>?

<script>
  window.fsAttributes = window.fsAttributes || [];
  window.fsAttributes.push([
    'cmsload',
    (listInstances) => {
      console.log('cmsload Successfully loaded!');

      document.querySelector('.your-trigger-button-class').click();
    },
  ]);
</script>

Hi Luis,
I used this script and replaced the select by a button but I still can’t figure out where is the problem :grimacing:
If you have any idea :pray:

Hey @Fabien_ouiflow! On my end, it is sorting the list from oldest to newest post. Is this not the desired behavior?

You can add the setting below to the trigger to sort the list from newer to older.

If the issue is not this please share a video explaining what is wrong :pray:

Hi @Support-Luis ,
I found something in the date format :
If I use a format with numbers (e.g. 6/11/2023) the sorting is done on the first digit of the string, then the 2nd and so on.
This makes the filter inconsistent:

If I switch to an alphabetical format (e.g. Nov 6, 2023), the sorting is performed as desired :

The only problem is that the date format doesn’t correspond to the European format, but we could certainly add a script to change this (but we’ll have to check that it works with the attributes).

Thanks for your help

Do let me know if you need any help to implement the script! You can take a look at the Attributes API for more info on how to add code after any solution has executed.

1 Like

Hi @Support-Luis
Hop you’re well.

In fact, I still have the sorting problem but only for the French language :

Do you have any idea what the problem is?

Thanks

hey @Fabien_ouiflow! Is there a direct link to this page? Or is the problem present when switching the language in the footer?

Hi @Support-Luis, the problem occurs in a direct link or even by switching : Seyna - Toutes nos ressources pour les courtiers

Thanks

Hey @Fabien_ouiflow, have you implemented the script where the date format is changed?

This might be the root of the issue

Hi @Support-Luis
No, we haven’t added any scripts.
Just translation via Weglot that could cause this problem?

We previously discussed the format change where you said

The only problem is that the date format doesn’t correspond to the European format, but we could certainly add a script to change this (but we’ll have to check that it works with the attributes).

I’m just wondering if this script was ever put in place as the CMS Sort and if it did how does it work?

We can move the JS that clicks the sort button to only work after Weglot finished translating the page + the format is changed

Hello @Support-Luis ,
I hope you’re well.
We solved the problem this way. I’ll add here if this ever happens to others:
Weglot performs a translation of the dates which changes the format and therefore impacts the sorting with the attributes. So we simply added a hidden div with the date we want to sort on. We then exclude this div from the weglot translation to be sure that the sorting is still carried out correctly.
This allows you to keep the translation by having a date for the format and a date for sorting that is hidden (using the same CMS field)

Thank you for your help and see you soon :grinning:

1 Like