1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 07:47:00 +02:00

Add new PageFrontEdit::getAjaxPostUrl() hookable method

This commit is contained in:
Ryan Cramer
2024-07-30 11:39:18 -04:00
parent 137b2aa50b
commit 2a84f12018

View File

@@ -13,6 +13,7 @@
* @property bool|int $inlineLimitPage Limit editor to current page only * @property bool|int $inlineLimitPage Limit editor to current page only
* @property array $inlineAllowFieldtypes * @property array $inlineAllowFieldtypes
* @method Page getPage() Get page being edited (3.0.208+) * @method Page getPage() Get page being edited (3.0.208+)
* @method string getAjaxPostUrl() Get URL that ajax save requests should POST to (3.0.242+)
* *
*/ */
@@ -203,6 +204,19 @@ class PageFrontEdit extends WireData implements Module {
return $this->page; return $this->page;
} }
/**
* Get URL that ajax save should post to
*
* #pw-hooker
*
* @return string
* @since 3.0.242
*
*/
public function ___getAjaxPostUrl() {
return $this->wire()->page->url;
}
/** /**
* Set the page being edited * Set the page being edited
* *
@@ -750,6 +764,9 @@ class PageFrontEdit extends WireData implements Module {
$tinymceUrl = ''; $tinymceUrl = '';
} }
$ajaxPostUrl = $this->getAjaxPostUrl();
if($draft) $ajaxPostUrl .= (strpos($ajaxPostUrl, '?') ? '&' : '?') . "draft=$draft";
$configJS = $config->js(); $configJS = $config->js();
$configJS['modals'] = $config->modals; $configJS['modals'] = $config->modals;
$configJS['urls'] = array( $configJS['urls'] = array(
@@ -768,7 +785,7 @@ class PageFrontEdit extends WireData implements Module {
'fa' => $config->urls->adminTemplates . "styles/font-awesome/css/font-awesome.min.css", 'fa' => $config->urls->adminTemplates . "styles/font-awesome/css/font-awesome.min.css",
), ),
'adminTheme' => $adminTheme ? $adminTheme : 'AdminThemeDefault', 'adminTheme' => $adminTheme ? $adminTheme : 'AdminThemeDefault',
'pageURL' => $this->wire()->page->url . ($draft ? "?draft=$draft" : "") 'pageURL' => $ajaxPostUrl
); );
$scripts[] = $scripts[] =