jan Posted March 26, 2014 Posted March 26, 2014 Hi there, I have a template with a field type page. Now I try to remove one of the pages inside this field. I think I'm kind of blind – it won't do what I want it do foreach ($myPage->pageField as $pageInField) { if( /* condition to find page to remove */ ) { $myPage->pageField->remove($pageInField); break; } } Thank you!!!
kongondo Posted March 26, 2014 Posted March 26, 2014 Something like this could probably work.... $x = $pages->get(1412);//necessarily verbose - could have done this in foreach foreach ($x->myPageField as $f) { if ($f->name == 'example') {//set your condition $x->of(false); $x->myPageField->remove($f); $x->save(); } } 2
bracketfire Posted November 29, 2014 Posted November 29, 2014 I have a PageField that holds a single page. I've been trying to find the proper way to unset it, I've seen an example of using "unset" but that doesn't feel right, or very processwire-ish. Right now, I'm using $facility->region_page = new NullPage(); But this also, just doesn't feel right but appears to work. Is there a best practice for unsetting a pagefield?
Macrura Posted November 29, 2014 Posted November 29, 2014 @bracketfire - this should work: $facility->region_page = '';
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