Page 1 of 1

sorting order based on relationship

PostPosted: Wed Sep 21, 2011 4:57 am
by Jean
Hi Steve,

I have a relationship between 2 tables
Code: Select all
lieu : id_lieu, nom
programmation: id_programmation, id_lieu...

On my programmation list view, if I click on the id_lieu header, my items are sorted by id_lieu and not lieu.nom.
The relationships.ini is well set up...
My url is
Code: Select all
-table=programmation&-sort=id_lieu

How can I sort by lieu.nom instead of programmation.id_lieu ?

Thank you

Jean

Re: sorting order based on relationship

PostPosted: Wed Sep 21, 2011 9:36 am
by shannah
Create a grafted field on your programmation table for this. Then hide the id_lieu in list view and show nom instead.
e.g.
Code: Select all
__sql__ = "select p.*, l.nom as lieu_nom from programmation p left join lieu l on p.id_lieu=l.id_lieu"

[lieu_nom]
order=10

[id_lieu]
visibility:list=hidden



-Steve

Re: sorting order based on relationship

PostPosted: Wed Sep 21, 2011 10:01 am
by Jean
thank you Steve for your explanation, I'll add it in the wiki.

Jean