1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 15:57:01 +02:00

Refactor the Templates::getParentPage() method. This should hopefully fix processwire/processwire-issues#1929 ... also removed the Template::noShortcut check from that method since it didn't really belong there, and moved it to ProcessPageList and ProcessPageLister. Some phpdoc updates as well.

This commit is contained in:
Ryan Cramer
2024-07-01 10:59:20 -04:00
parent d5faf861dc
commit dff3e8aaeb
4 changed files with 41 additions and 58 deletions

View File

@@ -185,6 +185,7 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
if(!$user->isGuest() && $user->hasPermission('page-edit')) {
foreach($templates as $template) {
if($template->noShortcut) continue;
$parent = $template->getParentPage(true);
if(!$parent) continue;
if($parent->id) {

View File

@@ -2221,6 +2221,9 @@ class ProcessPageLister extends Process implements ConfigurableModule {
if($this->parent && $this->parent->id && $this->parent->addable()) {
$action = "?parent_id={$this->parent->id}";
} else if($this->template && $this->template->noShortcut) {
// not allowed in add-new list
} else if($this->template && ($parent = $this->template->getParentPage(true))) {
if($parent->id) {
$action = "?parent_id=$parent->id"; // defined parent