adrianmak Posted March 10, 2015 Posted March 10, 2015 I added a new field of an existing template where this template has already hundreds of page had beed created. I put following code on home page temporary. $result = $pages->find("template=mytemplate"); foreach ($result as $p) { $p->new_field = time(); $p->save(); } After refreshing the home page, all pages with this template should be updated. I log-in to backend admin, and found that the field is still empty.
adrian Posted March 10, 2015 Posted March 10, 2015 That should work and works fine here. I am wondering if there is some issue with the "hundreds of pages"? How many fields are there in the template? One thing to try might be to: $page->save("new_field"); since this only saves that one field, rather than all of them. I don't think it is necessary in this case, but it is always good to do: $p->of(false); before saving. Are there any errors being logged?
adrianmak Posted March 10, 2015 Author Posted March 10, 2015 That should work and works fine here. I am wondering if there is some issue with the "hundreds of pages"? How many fields are there in the template? One thing to try might be to: $page->save("new_field"); since this only saves that one field, rather than all of them. I don't think it is necessary in this case, but it is always good to do: $p->of(false); before saving. Are there any errors being logged? I should have $p->of(false); it
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