useSeoTemplate(); } /** * Set page alias for * @param string $page */ public function aliasFor(string $page) { $this->alias = trim($page, '\\'); } /** * Get page alias for * @return string */ public function getAliasFor() { return $this->alias; } /** * Set success message as template * @param string $title * @param string|array $message * @param array $opts * @return string */ public function successMessage($title, $message, array $opts = []) { $this->skipSeo(); return Site::showMessage($title, $message, true, $opts); } /** * Set forbidden message as template * @param string $title * @param string|array $message * @param array $opts ['auth' - true/false, ...] * @return string */ public function forbiddenMessage($title, $message, array $opts = []) { $this->skipSeo(); return Site::showMessage($title, $message, false, $opts); } /** * Handle page request * Method called by router * @return mixed */ public function __invoke() { if (method_exists($this, 'handle')) { if (! $this->app->adminPanel()) { $this->loadSettings(); } return $this->handle(...func_get_args()) ?? $this; } return $this; } /** * Handle submit/action request and prevent render * @return mixed */ protected function renderContent() { if (! $this->app->adminPanel()) { $this->loadSettings(); $this->fillSettings(); } if ($this->isSubmitAction()) { if ($response = $this->handleActionRequest('submit')) { return $response; } } else { if ($response = $this->handleActionRequest()) { return $response; } } return parent::renderContent(); } /** * Init before render to fill seo data used in template (titleh1, breadcrumbs ...) * @return bool|void */ protected function beforeRender() { if (parent::beforeRender() === false) { return false; } if ($this->skipSeo) { return; } if (is_array($this->data)) { $this->seoSettings(); $this->seo(); # Update last breadcrumb title to breadcrumb from seo settings if (! empty($this->data['breadcrumb']) && $this->hasBreadcrumbs()) { $this->breadcrumbs->update(['title' => $this->data['breadcrumb']]); } # Wrap seotext in default seotext template if (! empty($this->data['seotext'])) { $this->data['seotext'] = $this->view->template('seotext', [ 'seotext' => $this->data['seotext'], ], 'site'); } } } }