/** * @param InputInterface $input * @param $name * @param $userContainer * @param $pass * @return \Page */ public function createUser(InputInterface $input, $name, $userContainer, $pass) { $user = new \Page(); $user->template = 'user'; $user->setOutputFormatting(false); $user->parent = $userContainer; $user->name = $name; $user->title = $name; if (!empty($pass)) { $user->pass = $pass; } $email = $input->getOption('email'); if ($email) { $user->email = $email; } return $user; }
<?php // create a page via API $p = new Page(); $p->setOutputFormatting(false); $p->template = 'products'; $p->parent = wire('pages')->get('/'); $p->name = "my-api-generated-new-pw-page"; // same as MODX alias $p->title = "My API-generated new PW page"; $p->fieldname = "my field value"; $p->save(); echo "page ID {$p->id} created!<br>";
public function renderChild(Page $page) { $outputFormatting = $page->outputFormatting; $page->setOutputFormatting(true); $class = ''; $type = ''; $note = ''; $label = ''; $icons = array(); if (in_array($page->id, $this->systemIDs)) { $type = 'System'; if ($page->id == $this->config->http404PageID) { $label = $this->_('404 Page Not Found'); } else { if ($page->id == $this->config->adminRootPageID) { $label = $this->_('Admin'); } else { if ($page->id == $this->config->trashPageID && isset($this->actionLabels['trash'])) { $label = $this->actionLabels['trash']; } } } // Label for 'Trash' page in PageList // Overrides page title if used // if label is not overridden by a language pack, make $label blank to use the page title instead if (in_array($label, array('Trash', 'Admin', '404 Page Not Found'))) { $label = ''; } } if ($page->getAccessParent() === $page && $page->parent->id) { $accessTemplate = $page->getAccessTemplate(); if ($accessTemplate && $accessTemplate->hasRole('guest')) { $accessTemplate = $page->parent->getAccessTemplate(); if ($accessTemplate && !$accessTemplate->hasRole('guest') && !$page->isTrash()) { $class .= ' PageListAccessOn'; $icons[] = 'key fa-flip-horizontal'; } } else { $accessTemplate = $page->parent->getAccessTemplate(); if ($accessTemplate && $accessTemplate->hasRole('guest')) { $class .= ' PageListAccessOff'; $icons[] = 'key'; } } } if ($page->id == $this->config->trashPageID) { $note = "< " . $this->_("Trash open: drag pages below here to trash them"); // Message that appears next to the Trash page when open $icons = array('trash-o'); // override any other icons } else { if ($page->hasStatus(Page::statusTemp)) { $icons[] = 'bolt'; } if ($page->hasStatus(Page::statusLocked)) { $icons[] = 'lock'; } if ($page->hasStatus(Page::statusDraft)) { $icons[] = 'paperclip'; } } if (!$label) { $label = $this->getPageLabel($page); } if (count($icons)) { foreach ($icons as $n => $icon) { $label .= "<i class='PageListStatusIcon fa fa-fw fa-{$icon}'></i>"; } } $a = array('id' => $page->id, 'label' => $label, 'status' => $page->status, 'numChildren' => $page->numChildren(1), 'path' => $page->template->slashUrls || $page->id == 1 ? $page->path() : rtrim($page->path(), '/'), 'template' => $page->template->name, 'actions' => array_values($this->getPageActions($page))); if ($class) { $a['addClass'] = trim($class); } if ($type) { $a['type'] = $type; } if ($note) { $a['note'] = $note; } $page->setOutputFormatting($outputFormatting); return $a; }