{# If there were any validation errors, a `contact` variable will be passed to the template, which contains the posted values and validation errors. If that’s not set, we’ll default to a new contact. #} {% set contact = contact ?? create('putyourlightson\\campaign\\elements\\ContactElement') %} <form id="subscribe-form" method="post" action=""> {{ csrfInput() }} <input type="hidden" name="action" value="campaign/forms/subscribe" /> <input type="hidden" name="mailingList" value="{{ mailingList.slug }}" /> <input type="hidden" name="redirect" value="{{ 'om-oss/nyhetsbrev?registration=success'|hash }}" /> <div class="form__row"> <div class="form__column"> <h3><label class="form__label form__label--required" for="name">Fornavn</label></h3> <input class="form__input" id="name" type="text" name="fields[firstName]" value="{{ contact.firstName }}" required /> {{ contact.getFirstError('firstName') }} </div> <div class="form__column">
// Add deprecated support for the old DateTime methods if ($object instanceof \DateTime && ($value = self::_dateTimeAttribute($object, $item, $type)) !== false) { return $value; } try { return \twig_get_attribute($env, $source, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck); } catch (UnknownMethodException $e) { // Copy twig_get_attribute()'s BadMethodCallException handling if ($ignoreStrictCheck || !$env->isStrictVariables()) { return null; } throw new RuntimeError($e->getMessage(), -1, $source);
set, we’ll default to a new contact. #} {% set contact = contact ?? create('putyourlightson\\campaign\\elements\\ContactElement') %} <form id="subscribe-form" method="post" action=""> {{ csrfInput() }} <input type="hidden" name="action" value="campaign/forms/subscribe" /> <input type="hidden" name="mailingList" value="{{ mailingList.slug }}" /> <input type="hidden" name="redirect" value="{{ 'om-oss/nyhetsbrev?registration=success'|hash }}" /> <div class="form__row"> <div class="form__column"> <h3><label class="form__label form__label--required" for="name">Fornavn</label></h3> <input class="form__input" id="name" type="text" name="fields[firstName]" value="{{ contact.firstName }}" required />
return ob_get_clean(); } protected function displayWithErrorHandling(array $context, array $blocks = []) { try { $this->doDisplay($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($this->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{ return $this->blocks; } public function display(array $context, array $blocks = []) { $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); } public function render(array $context) { $level = ob_get_level(); if ($this->env->isDebug()) {
{% embed 'sections/pages/__base' %} {% block afterParagraphs %} {# {% include 'components/_mailChimpSubscriptionForm' %} #} {% include 'newsletter/_subscribe' %} <br /><br /><br /><br /><br /><br /><br /><br /> {% include 'newsletter/_unsubscribe' %} {% endblock %}
if (null !== $template && !$template instanceof self) { throw new \LogicException('A block must be a method on a \Twig\Template instance.'); } if (null !== $template) { try { $template->$block($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($template->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{% block paragraphs %} {% if entry.paragraphs|length %} {% set paragraphs = entry.paragraphs.all %} {% include 'components/_paragraphPrinter' with {paragraphs: paragraphs} only %} {% endif %} {% endblock %} {% block afterParagraphs %} {% endblock %} </div> {% endblock %} {% block afterBody %} {% endblock %} </div>
if (null !== $template && !$template instanceof self) { throw new \LogicException('A block must be a method on a \Twig\Template instance.'); } if (null !== $template) { try { $template->$block($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($template->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{% endblock %} {% block content %} <div class="entry__content"> {% block beforeBody %} {% endblock %} {% block body %} <div class="entry__body"> {% block beforeParagraphs %} {% endblock %} {% block paragraphs %} {% if entry.paragraphs|length %} {% set paragraphs = entry.paragraphs.all %}
if (null !== $template && !$template instanceof self) { throw new \LogicException('A block must be a method on a \Twig\Template instance.'); } if (null !== $template) { try { $template->$block($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($template->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{% set passwordProtected = entry.passwordProtected is defined and entry.passwordProtected %} <div class="entry__container"{% if passwordProtected %}data-password-protected{% endif %}> {% block head %} {% include 'components/_masthead' with {noBanner: noBanner, banner: banner, title: title, noByline: noByline, byline: byline, intro: intro} %} {% endblock %} {% block content %} <div class="entry__content"> {% block beforeBody %} {% endblock %} {% block body %} <div class="entry__body"> {% block beforeParagraphs %}
if (null !== $template && !$template instanceof self) { throw new \LogicException('A block must be a method on a \Twig\Template instance.'); } if (null !== $template) { try { $template->$block($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($template->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{% endif %} {% endif %} {% endblock %} <article class="entry"> {% block beforeContainer %} {% endblock %} {% block container %} {% set passwordProtected = entry.passwordProtected is defined and entry.passwordProtected %} <div class="entry__container"{% if passwordProtected %}data-password-protected{% endif %}> {% block head %} {% include 'components/_masthead' with {noBanner: noBanner, banner: banner, title: title, noByline: noByline, byline: byline, intro: intro} %} {% endblock %}
return ob_get_clean(); } protected function displayWithErrorHandling(array $context, array $blocks = []) { try { $this->doDisplay($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($this->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{ return $this->blocks; } public function display(array $context, array $blocks = []) { $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); } public function render(array $context) { $level = ob_get_level(); if ($this->env->isDebug()) {
{% embed 'sections/pages/__base' %} {% block afterParagraphs %} {# {% include 'components/_mailChimpSubscriptionForm' %} #} {% include 'newsletter/_subscribe' %} <br /><br /><br /><br /><br /><br /><br /><br /> {% include 'newsletter/_unsubscribe' %} {% endblock %}
return ob_get_clean(); } protected function displayWithErrorHandling(array $context, array $blocks = []) { try { $this->doDisplay($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($this->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{ return $this->blocks; } public function display(array $context, array $blocks = []) { $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); } public function render(array $context) { $level = ob_get_level(); if ($this->env->isDebug()) {
{% embed 'sections/pages/__base' %} {% block afterParagraphs %} {# {% include 'components/_mailChimpSubscriptionForm' %} #} {% include 'newsletter/_subscribe' %} <br /><br /><br /><br /><br /><br /><br /><br /> {% include 'newsletter/_unsubscribe' %} {% endblock %}
return ob_get_clean(); } protected function displayWithErrorHandling(array $context, array $blocks = []) { try { $this->doDisplay($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($this->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{ return $this->blocks; } public function display(array $context, array $blocks = []) { $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); } public function render(array $context) { $level = ob_get_level(); if ($this->env->isDebug()) {
{% extends '_layout/_layout' %} {% block header %} {% include 'parts/_header' %} {% endblock %} {% block main %} {% if entry|default(null) %} {% include ['sections/' ~ entry.section.handle ~ '/_' ~ entry.type, 'sections/' ~ entry.section.handle ~ '/_index'] %} {% endif %} <div id="player_pane"> <div id="player_content"></div> </div> {% endblock %} {% block footer %}
if (null !== $template && !$template instanceof self) { throw new \LogicException('A block must be a method on a \Twig\Template instance.'); } if (null !== $template) { try { $template->$block($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($template->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
</noscript> #} <!-- End Google Tag Manager (noscript) --> <header> {% block header %}{% endblock %} </header> <main> {% block main %}{% endblock %} </main> <footer> {% block footer %}{% endblock %} </footer> {# <div class="survey" data-survey>
return ob_get_clean(); } protected function displayWithErrorHandling(array $context, array $blocks = []) { try { $this->doDisplay($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($this->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{ return $this->blocks; } public function display(array $context, array $blocks = []) { $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); } public function render(array $context) { $level = ob_get_level(); if ($this->env->isDebug()) {
{% extends '_layout/_layout' %} {% block header %} {% include 'parts/_header' %} {% endblock %} {% block main %} {% if entry|default(null) %} {% include ['sections/' ~ entry.section.handle ~ '/_' ~ entry.type, 'sections/' ~ entry.section.handle ~ '/_index'] %}
return ob_get_clean(); } protected function displayWithErrorHandling(array $context, array $blocks = []) { try { $this->doDisplay($context, $blocks); } catch (Error $e) { if (!$e->getSourceContext()) { $e->setSourceContext($this->getSourceContext()); } // this is mostly useful for \Twig\Error\LoaderError exceptions
{ return $this->blocks; } public function display(array $context, array $blocks = []) { $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks)); } public function render(array $context) { $level = ob_get_level(); if ($this->env->isDebug()) {
if ($this->env->isDebug()) { ob_start(); } else { ob_start(function () { return ''; }); } try { $this->display($context); } catch (\Throwable $e) { while (ob_get_level() > $level) { ob_end_clean(); } throw $e;
* @param array $context An array of parameters to pass to the template */ public function render(array $context = []): string { // using func_get_args() allows to not expose the blocks argument // as it should only be used by internal code return $this->template->render($context, \func_get_args()[1] ?? []); } /** * Displays the template. * * @param array $context An array of parameters to pass to the template
* @throws LoaderError When the template cannot be found * @throws SyntaxError When an error occurred during compilation * @throws RuntimeError When an error occurred during rendering */ public function render($name, array $context = []) { return $this->load($name)->render($context); } /** * Displays a template. * * @param string|TemplateWrapper $name The template name
// Render and return $renderingTemplate = $this->_renderingTemplate; $this->_renderingTemplate = $template; $e = null; try { $output = $this->getTwig()->render($template, $variables); } catch (\Throwable $e) { // throw it later } $this->_renderingTemplate = $renderingTemplate; $this->setTemplateMode($oldTemplateMode);
$isRenderingPageTemplate = $this->_isRenderingPageTemplate; $this->_isRenderingPageTemplate = true; $e = null; try { $this->beginPage(); echo $this->renderTemplate($template, $variables); $this->endPage(); } catch (\Throwable $e) { // throw it later } $this->_isRenderingPageTemplate = $isRenderingPageTemplate;
} // Prevent a response formatter from overriding the content-type header $this->response->format = YiiResponse::FORMAT_RAW; // Render and return the template $this->response->data = $view->renderPageTemplate($template, $variables, $templateMode); // Set the MIME type for the request based on the matched template's file extension (unless the // Content-Type header was already set, perhaps by the template via the {% header %} tag) $headers = $this->response->getHeaders(); if (!$headers->has('content-type')) { $templateFile = StringHelper::removeRight(strtolower($view->resolveTemplate($template)), '.twig');
// Merge any additional route params $routeParams = Craft::$app->getUrlManager()->getRouteParams(); unset($routeParams['template'], $routeParams['template']); $variables = array_merge($variables, $routeParams); return $this->renderTemplate($template, $variables); } /** * Shows the 'offline' template. * * @return Response
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
/** * @inheritdoc */ public function runAction($id, $params = []) { try { return parent::runAction($id, $params); } catch (\Throwable $e) { if ($this->request->getAcceptsJson()) { Craft::$app->getErrorHandler()->logException($e); if (!YII_DEBUG && !$e instanceof UserException) { $message = Craft::t('app', 'A server error occurred.'); } else {
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
* @param string $route * @param array $params * @return Response|null The result of the action, normalized into a Response object */ public function runAction($route, $params = []) { $result = parent::runAction($route, $params); if ($result !== null) { if ($result instanceof Response) { return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
if (($response = $this->_processActionRequest($request)) !== null) { return $response; } // If we're still here, finally let Yii do it's thing. try { return parent::handleRequest($request); } catch (\Throwable $e) { $this->_unregisterDebugModule(); throw $e; } }
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
} define('CRAFT_ENVIRONMENT', 'dev'); // Load and run Craft $app = require CRAFT_VENDOR_PATH . '/craftcms/cms/bootstrap/web.php'; $app->run();
$_GET = [ 'p' => '/en/about-us/newsletter', ];