alxndre Posted May 15, 2017 Share Posted May 15, 2017 I'm trying to sort pages based on their parent's fields, which are page references. For instance: $someOrders = $pages->find("template=order, sort=parent.customer.id"); Here, order's parent has a template called 'orderslip' that has multiple 'order' children. Orderslip contains a page field called customer, and I want to sort based on the parent's customer's id. But i can't make it work. It throws out an exception: Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'customer' in 'order clause' (in /srv/rewwwards/wire/core/PageFinder.php line 410) I'm sure customer page field exists and it works everywhere else. It's just that this time, I'm trying to sort it from a page's 'parent' selector. Is it even possible do this? As always, any help is greatly appreciated. Thanks. Link to comment Share on other sites More sharing options...
Zeka Posted May 15, 2017 Share Posted May 15, 2017 Hi @Alxndre' Not sure, but looks like you should use sub-selectors in this case https://processwire.com/api/selectors/#sub-selectors 1 Link to comment Share on other sites More sharing options...
alxndre Posted May 15, 2017 Author Share Posted May 15, 2017 2 minutes ago, Zeka said: Hi @Alxndre' Not sure, but looks like you should use sub-selectors in this case https://processwire.com/api/selectors/#sub-selectors Hi, @Zeka, Sorry for the big edit, I was totally swimming in my head coding til morning. But thanks for pointing me to subselectors! I've been using ProcessWire since 2012, but never heard of it and it looks amazing. I should probably read the PW weekly more often. 1 Link to comment Share on other sites More sharing options...
Robin S Posted May 16, 2017 Share Posted May 16, 2017 The dot syntax for sub-selectors like what you are using should be fine too. The support for this dot syntax was expanded in 3.0.25 to include nested sub-selectors: https://processwire.com/blog/posts/pw-3.0.25/ I think including .id on the end may be redundant though - you could try simply sort=parent.customer 1 Link to comment Share on other sites More sharing options...
alxndre Posted May 16, 2017 Author Share Posted May 16, 2017 Searching using subfields values is working fine, for some reason, I can't make sorting with parent.pagefield work. Link to comment Share on other sites More sharing options...
Robin S Posted May 16, 2017 Share Posted May 16, 2017 1 hour ago, Alxndre' said: Searching using subfields values is working fine, for some reason, I can't make sorting with parent.pagefield work. I can confirm. Seems like a bug to me - I tried sorting on a range of different fieldtypes in the parent page and they all worked apart from a Page Reference field, which gives the error shown in the first post. @Alxndre', I suggest you create a GitHub issue for this so Ryan can take a look. 1 Link to comment Share on other sites More sharing options...
alxndre Posted May 16, 2017 Author Share Posted May 16, 2017 @Robin S thanks for confirming. I already submitted a bug report. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now