We have created a table that displays the number of "likes" that our content has. The "Like" field is a custom field created with Toolset and it's a single line field type. It has to be a single line and cannot be changed to a number field.
Is it possible to sort our table numerically even though this is a single line field?
You can see the table here: lien caché
And with the link I gave, you should see that the table is sorted by the 2nd column but it isn't in order. I've also attached a screenshot that shows how it is display for me.
Les langues: Anglais (English )Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Hi Marcus
I can see that the sorting isn't working for that Likes column, but I can't see why from the front end, can I get access to your site to take a closer look?
I'm afraid, though, that if this is a string field it will be sorted as a string, there isn't an option to change how it is sorted. It would need to be a number field to be sorted as a number.
I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.
Les langues: Anglais (English )Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Hi Marcus
When I check the curricula posts I see that they don't have a value stored for the Likes field, they have a custom shortcode (see screenshot).
Because the value stored in the database for the field is "[rating]" then when the table is sorted by that column, which happens with a new database query which specifies that field for the sort order, it fails because, well, there are no numbers to sort by.
Les langues: Anglais (English )Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
I'm not sure what your current solution is, but it needs to save a value in the postmeta table if you are to be able to order by it.
I know other clients have used the plugin Favorites (lien caché) which may require a little effort to integrate with Toolset, but I know it saves the favorite count in post meta as "simplefavorites_count" so you can output that in your View listing posts and it should work in your table sort.