mirror of
https://github.com/processwire/processwire.git
synced 2025-08-16 11:44:42 +02:00
Fix issue processwire/processwire-issues#1495
This commit is contained in:
@@ -1844,7 +1844,7 @@ class PagesEditor extends Wire {
|
||||
}
|
||||
|
||||
// detect template from parent (when possible)
|
||||
if(!$template && !empty($parent)) {
|
||||
if(!$template && !empty($parent) && empty($options['id'])) {
|
||||
$parent = is_object($parent) ? $parent : $this->pages->get($parent);
|
||||
if($parent->id) {
|
||||
if(count($parent->template->childTemplates) === 1) {
|
||||
@@ -1856,7 +1856,7 @@ class PagesEditor extends Wire {
|
||||
}
|
||||
|
||||
// detect parent from template (when possible)
|
||||
if($template && empty($parent) && count($template->parentTemplates) === 1) {
|
||||
if($template && empty($parent) && empty($options['id']) && count($template->parentTemplates) === 1) {
|
||||
$parentTemplates = $template->parentTemplates();
|
||||
if($parentTemplates->count()) {
|
||||
$numParents = $this->pages->count("template=$parentTemplates, include=all");
|
||||
@@ -1875,6 +1875,7 @@ class PagesEditor extends Wire {
|
||||
|
||||
if(isset($options['id']) && ctype_digit("$options[id]") && (int) $options['id'] > 0) {
|
||||
$options['id'] = (int) $options['id'];
|
||||
if($parent && "$options[id]" === "$parent") unset($options['parent']);
|
||||
} else {
|
||||
unset($options['id']);
|
||||
}
|
||||
|
@@ -407,6 +407,7 @@ class PagesLoader extends Wire {
|
||||
|
||||
if($lazy) {
|
||||
// lazy load: create empty pages containing only id and template
|
||||
$templates = $this->wire()->templates;
|
||||
$pages = $this->pages->newPageArray($loadOptions);
|
||||
$pages->finderOptions($options);
|
||||
$pages->setDuplicateChecking(false);
|
||||
@@ -419,7 +420,7 @@ class PagesLoader extends Wire {
|
||||
if(isset($templatesByID[$templateID])) {
|
||||
$template = $templatesByID[$templateID];
|
||||
} else {
|
||||
$template = $this->wire('templates')->get($templateID);
|
||||
$template = $templates->get($templateID);
|
||||
$templatesByID[$templateID] = $template;
|
||||
}
|
||||
$page = $this->pages->newPage($template);
|
||||
@@ -441,6 +442,7 @@ class PagesLoader extends Wire {
|
||||
|
||||
} else if($loadPages) {
|
||||
// parent_id is null unless a single parent was specified in the selectors
|
||||
$templates = $this->wire()->templates;
|
||||
$parent_id = $pageFinder->getParentID();
|
||||
$idsSorted = array();
|
||||
$idsByTemplate = array();
|
||||
@@ -462,7 +464,7 @@ class PagesLoader extends Wire {
|
||||
$unsortedPages = $this->pages->newPageArray($loadOptions);
|
||||
foreach($idsByTemplate as $tpl_id => $ids) {
|
||||
$opt = $loadOptions;
|
||||
$opt['template'] = $this->wire('templates')->get($tpl_id);
|
||||
$opt['template'] = $templates->get($tpl_id);
|
||||
$opt['parent_id'] = $parent_id;
|
||||
$unsortedPages->import($this->getById($ids, $opt));
|
||||
}
|
||||
@@ -482,7 +484,7 @@ class PagesLoader extends Wire {
|
||||
$pages = $this->pages->newPageArray($loadOptions);
|
||||
reset($idsByTemplate);
|
||||
$opt = $loadOptions;
|
||||
$opt['template'] = $this->wire('templates')->get(key($idsByTemplate));
|
||||
$opt['template'] = $templates->get(key($idsByTemplate));
|
||||
$opt['parent_id'] = $parent_id;
|
||||
$pages->import($this->getById($idsSorted, $opt));
|
||||
}
|
||||
@@ -1168,9 +1170,10 @@ class PagesLoader extends Wire {
|
||||
$page = $this->pages->newPage(array(
|
||||
'pageClass' => $pageClass,
|
||||
'template' => $pageTemplate ? $pageTemplate : $row['templates_id'],
|
||||
'parent' => $row['parent_id'],
|
||||
));
|
||||
}
|
||||
unset($row['templates_id']);
|
||||
unset($row['templates_id'], $row['parent_id']);
|
||||
foreach($row as $key => $value) $page->set($key, $value);
|
||||
if($options['cache'] === false) $page->loaderCache = false;
|
||||
$page->instanceID = ++self::$pageInstanceID;
|
||||
|
Reference in New Issue
Block a user