/** * Listener to setup blog item and its virtual page * @param <type> $event */ public function postInsert($event) { // Create a virtual page for this item $page = new aPage(); $page['slug'] = $this->getVirtualPageSlug(); // Search is good, let it happen $page['view_is_secure'] = false; // ... But not if we're unpublished $page->archived = !($this->status === 'published'); $page->save(); $this->Page = $page; // Create a slot for the title and add to the virtual page $title = $page->createSlot('aText'); $title->value = 'Untitled'; $title->save(); $page->newAreaVersion('title', 'add', array('permid' => 1, 'slot' => $title)); // Create a slot to index the tags and categories in search. $catTag = $page->createSlot('aText'); $catTag->value = ''; $catTag->save(); $page->newAreaVersion('catTag', 'add', array('permid' => 1, 'slot' => $catTag)); // Make default values for this item $this['slug'] = 'untitled-' . $this['id']; $this['title'] = 'untitled'; $this['slug_saved'] = false; // This prevents post preupdate from running after the next save $this->update = false; $this->save(); }