mirror of
https://github.com/processwire/processwire.git
synced 2025-08-17 04:04:13 +02:00
Attempt fix for processwire/processwire-issues#1358
This commit is contained in:
@@ -463,7 +463,10 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
|
|||||||
*/
|
*/
|
||||||
public function ___execute() {
|
public function ___execute() {
|
||||||
|
|
||||||
$input = $this->wire('input');
|
$input = $this->wire()->input;
|
||||||
|
$config = $this->wire()->config;
|
||||||
|
$session = $this->wire()->session;
|
||||||
|
|
||||||
$this->headline($this->_('Add New')); // Headline
|
$this->headline($this->_('Add New')); // Headline
|
||||||
|
|
||||||
if(!$this->parent_id) {
|
if(!$this->parent_id) {
|
||||||
@@ -480,7 +483,7 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
|
|||||||
|
|
||||||
$template_id = (int) $input->post('template'); // note POST uses 'template' and GET uses 'template_id'
|
$template_id = (int) $input->post('template'); // note POST uses 'template' and GET uses 'template_id'
|
||||||
if(!$template_id) $template_id = (int) $input->get('template_id');
|
if(!$template_id) $template_id = (int) $input->get('template_id');
|
||||||
if($template_id) $this->template = $this->wire('templates')->get($template_id);
|
if($template_id) $this->template = $this->wire()->templates->get($template_id);
|
||||||
|
|
||||||
if(!$this->parent_id && count($this->predefinedParents)) {
|
if(!$this->parent_id && count($this->predefinedParents)) {
|
||||||
$this->parent_id = $this->predefinedParents->first()->id;
|
$this->parent_id = $this->predefinedParents->first()->id;
|
||||||
@@ -496,13 +499,23 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
|
|||||||
throw new WireException($this->errors('string'));
|
throw new WireException($this->errors('string'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if page has a custom ProcessPageType for editing/adding then redirect to its add URL instead
|
||||||
if($this->parent->template->name === 'admin' && $this->wire()->page->id != $this->parent->id) {
|
if($this->parent->template->name === 'admin' && $this->wire()->page->id != $this->parent->id) {
|
||||||
$process = $this->parent->process;
|
$process = $this->parent->process;
|
||||||
if($process && wireInstanceOf($process, 'ProcessPageType')) {
|
if($process && wireInstanceOf($process, 'ProcessPageType')) {
|
||||||
$this->wire()->session->location($this->parent->url . 'add/');
|
$session->location($this->parent->url . 'add/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the following does the same as the block of code above for a custom ProcessPageType
|
||||||
|
// but is necessary for the case of when custom $config->usersPageIDs is in use since
|
||||||
|
// the parent template may not be 'admin' and user pages may be outside of admin structure
|
||||||
|
if(in_array($this->parent_id, $config->usersPageIDs) && $this->wire()->process != 'ProcessUser') {
|
||||||
|
$url = $config->urls->admin . "access/users/add/?parent_id=$this->parent_id";
|
||||||
|
if($template_id && in_array($template_id, $config->userTemplateIDs)) $url .= "&template_id=$template_id";
|
||||||
|
$session->location($url);
|
||||||
|
}
|
||||||
|
|
||||||
if(count($this->parent->template->childTemplates) == 1) {
|
if(count($this->parent->template->childTemplates) == 1) {
|
||||||
// only one type of template is allowed for the parent
|
// only one type of template is allowed for the parent
|
||||||
$childTemplates = $this->parent->template->childTemplates;
|
$childTemplates = $this->parent->template->childTemplates;
|
||||||
|
Reference in New Issue
Block a user