nghi Posted January 2, 2014 Posted January 2, 2014 Figured it out. public function init() { $this->pages->addHookAfter('save', $this, 'generateRegionSubPages'); } public function generateRegionSubPages(HookEvent $event) { $page = $event->arguments[0]; if (!$page->isTrash && $page->template->name == 'portal') { $templates = array( array('name' => 'blog', 'title' => 'News'), array('name' => 'volunteers', 'title' => 'Volunteers'), array('name' => 'gallery', 'title' => 'Gallery'), array('name' => 'events', 'title' => 'Events'), array('name' => 'calendar', 'title' => 'Calendar') ); foreach($templates as $template) { if ($page->children('template=' . $template['name'])->count()==0) { $sub_page = new Page(); $sub_page->template = $template['name']; $sub_page->parent = $page; $sub_page->name = $template['title']; $sub_page->save(); } } } } What I need: To be able to auto generate a page from a form that will also create multiple child pages using different templates I'm not really sure how I can accomplish this or how to get started. Can someone give me some advice?
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