Search the Community
Showing results for tags 'page save hook'.
-
Hi i need some help to solve this. I need to save a specific value when saving a page $p = $pages->get('template=customer_project'); $p->location = "Hello world"; $page->save($p); This is my code right now in ready.php. location is my field "text field" inside template "customer_project". Right now when i refresh a page with the template it only populates one page? I want every page that has this field "location" to say Hello world and save it to the database? Don´t know if a hook is better.. PLEASE HELP!!!
-
Hello, I have a page field type (Multiple pages(PageArray)) with the input field type as AsmSelect. The admin users can select one or more pages from a list in the admin area. Some of those pages have children and if a checkbox is selected and the parent page has been added to the list, then I want to add the child pages as well on page save. So in admin.php I am trying to set those id's, but I can't get them to save. Hopefully the code clears up what I am trying to do. I appreciate any assistance. $pages->addHookAfter('save', function($event) { $pages = $event->object; $page = $event->arguments(0); //check if on template if($page->template == 'item') { //is the checkbox checked to add children if ($page->add_children == 1) { //get the values in the page field type field foreach ($page->page_assignment as $child) { //if selected pages have childen if ($child->numChildren > 0) { //loop through those children foreach ($child->children as $grandchild) { //set values. //$page->set('page_assignment', array($grandchild->id)) $page->page_assignment = array($grandchild->id); //we got the id of the page we need to s $pages->error($grandchild->id); } } } } }
- 1 reply
-
- page field type
- asmselect
-
(and 1 more)
Tagged with: