Jump to content

Exclude pages from PageField (front-end)


a-ok
 Share

Recommended Posts

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

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");

 

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...