src/models/data/SeoData.php
private function _render ($template, $variables)
	{
		$craft = \Craft::$app;

		if ($template === null)
			return '';

		try {
			// If this is a CP request, render the title as if it was the frontend
			if ($craft->request->isCpRequest)
			{
				$site   = $craft->sites->currentSite;
				$tpMode = $craft->view->templateMode;
				$craft->sites->setCurrentSite($this->_element->site);
				$craft->view->setTemplateMode(View::TEMPLATE_MODE_SITE);

				$ret = \Craft::$app->view->renderObjectTemplate(
					$template,
					$variables
				);

				$craft->sites->setCurrentSite($site);
				$craft->view->setTemplateMode($tpMode);
			}
			else
			{
				$ret = \Craft::$app->view->renderObjectTemplate(
					$template,
					$variables
				);
			}
		} catch (\Exception $e) {
			$ret = 'ERROR: ' . $e->getMessage();
		}

		return $ret;
	}
private function _render ($template, $variables)
	{
		$craft = \Craft::$app;

		if ($template === null)
			return '';

		try {
			// If this is a CP request, render the title as if it was the frontend
			if ($craft->request->isCpRequest)
			{
				$site   = $craft->sites->currentSite;
				$tpMode = $craft->view->templateMode;
				$craft->sites->setCurrentSite($this->_element->site);
				$craft->view->setTemplateMode(View::TEMPLATE_MODE_SITE);

				$ret = \Craft::$app->view->renderObjectTemplate(
					$template,
					$variables
				);

				$craft->sites->setCurrentSite($site);
				$craft->view->setTemplateMode($tpMode);
			}
			else
			{
				$ret = \Craft::$app->view->renderObjectTemplate(
					$template,
					$variables
				);
			}
		} catch (\Exception $e) {
			$ret = 'ERROR: ' . $e->getMessage();
		}

		return $ret;
	}
@param $template
@param $variables

@return string
@throws \Throwable