1

I have a project where we display a table of books and a column in that table represents a playa field where 1 or more related authors may be selected. I would really like to then be able to sort on author with the first playa entry for each book being considered the 'primary' author and the sort apply to that...

enter image description here

The results I get when trying to order by this field appear to be rather random, wondering if this is partially related to Using Playa field to order channel entries list

1

Instead of sorting based on the contents of the TD, it would probably be better to set a data attribute to that TD and sort by that value. So instead of...

<td>2 Authors<br>Joe Bloggs<br>Bloggsy Malone</td>

You would want

<td data-primary_author="Joe Bloggs">2 Authors<br>Joe Bloggs<br>Bloggsy Malone</td>

Which could be achieved with

<td data-primary_author="{exp:playa:parents channel='author' limit='1'}{title}{/exp:playa:parents}">

You'd also have to adjust your JavaScript to sort by data attribute rather than contents.

1
  • Very creative idea! Filing this in my memory.
    – Anna_MediaGirl
    Feb 10 '15 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.