mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 02:04:35 +02:00
Update $pages->newPage() method so that it can also accept template name or ID for the template option
This commit is contained in:
@@ -1947,6 +1947,11 @@ class Pages extends Wire {
|
|||||||
|
|
||||||
unset($options['template'], $options['parent'], $options['pageClass']);
|
unset($options['template'], $options['parent'], $options['pageClass']);
|
||||||
|
|
||||||
|
if($template && !$template instanceof Template) {
|
||||||
|
$template = $this->wire()->templates->get($template);
|
||||||
|
if(!$template instanceof Template) $template = null;
|
||||||
|
}
|
||||||
|
|
||||||
if(strpos($class, "\\") === false) $class = wireClassName($class, true);
|
if(strpos($class, "\\") === false) $class = wireClassName($class, true);
|
||||||
|
|
||||||
$page = $this->wire(new $class($template));
|
$page = $this->wire(new $class($template));
|
||||||
|
Reference in New Issue
Block a user