a-ok Posted August 25, 2016 Share Posted August 25, 2016 Apologies if this has been answered before. I have a simple PageField set up, and on the front-end I'm wanting to split the pages selected into two variables; primary and secondary. I thought this would work but doesn't? $primary_tags = $article->article_tags->not("id=1336|1337|1338|1339|1327|1326|1328"); $secondary_tags = $article->article_tags->not("id=1042|1043|1044|1340|1341"); This is within the loop so $primary_tags should be returning all the pages selected via the PageField EXCEPT the ones listed, and the same goes for $secondary_tags. Any thoughts? Am I missing something? Link to comment Share on other sites More sharing options...
BitPoet Posted August 25, 2016 Share Posted August 25, 2016 not() modifies the original PageArray, so you need to populate your variables with a copy of the original PageArray before you filter them. ($primary_tags = $article->article_tags->slice(0))->not("id=1336|1337|1338|1339|1327|1326|1328"); ($secondary_tags = $article->article_tags->slice(0))->not("id=1042|1043|1044|1340|1341"); 2 Link to comment Share on other sites More sharing options...
a-ok Posted August 25, 2016 Author Share Posted August 25, 2016 This is great, thanks BitPoet. I'm unsure why I didn't think to slice it... so slicing it would effectively create a new instance of the PageArray? Link to comment Share on other sites More sharing options...
Robin S Posted August 25, 2016 Share Posted August 25, 2016 find() would also work here: $primary_tags = $article->article_tags->find("id!=1336|1337|1338|1339|1327|1326|1328"); $secondary_tags = $article->article_tags->find("id!=1042|1043|1044|1340|1341"); 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