suntrop Posted December 13, 2018 Share Posted December 13, 2018 I was trying to get pages that have grand children older than 14 days, but not newer than 14 days. $cities = wire('pages')->find('template=city, !children.children.created>"14 days ago"'); $cities = wire('pages')->find('template=city, children.children.created<"14 days ago"')->not('template=city, children.children.created>"14 days ago"'); $cities = wire('pages')->find('template=city, children.children.created<"14 days ago"')->remove('template=city, children.children.created>"14 days ago"'); The first one is, I guess, not supported by PW (not to mention something like created!>time), but the last two should work in my option. The filter() doesn't work either here. Please note, that all city pages have grand children older than 14 days, so I can't just find('template=cities, children.children.created<"14 days ago"') because that includes those pages having grand children from yesterday for example. Link to comment Share on other sites More sharing options...
Robin S Posted December 14, 2018 Share Posted December 14, 2018 8 hours ago, suntrop said: but the last two should work in my option. The filter() doesn't work either here. Times as strings are not supported for in-memory selectors, only PageFinder (database) selectors. You'll need to use timestamps (e.g. via strtotime). Link to comment Share on other sites More sharing options...
suntrop Posted December 14, 2018 Author Share Posted December 14, 2018 Hadn't luck with timestamp either. Changed it now to this, and it's working for me. Anyway, thanks for your answer! $remove = wire('pages')->find('template=city, children.children.created>"14 days ago"'); $cities = wire('pages')->find('template=city, children.children.created<"14 days ago"')->removeItems($remove); Link to comment Share on other sites More sharing options...
LostKobrakai Posted December 14, 2018 Share Posted December 14, 2018 Did you try: $cities = wire('pages')->find('template=city, children.children.created<"14 days ago", !children.children.created>"14 days ago"') Without the @ syntax the two selectors for children should work if they match on different children. Link to comment Share on other sites More sharing options...
suntrop Posted December 14, 2018 Author Share Posted December 14, 2018 1 hour ago, LostKobrakai said: $cities = wire('pages')->find('template=city, children.children.created<"14 days ago", !children.children.created>"14 days ago"') This one has a strange outcome. For example … find('template=city, children.children.created<"14 days ago"'); Result: Hamburg Berlin Hannover Wiesbaden find('template=city, children.children.created>"14 days ago"'); Result: Hamburg Bremen find('template=city, children.children.created<"14 days ago", !children.children.created>"14 days ago"'); Result: Hamburg 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