1

I am trying to set up a Craft CMS website with Twig. I have done all the setup but getting the following error when I try to open the website-

Twig_Error_Runtime

Variable "global" does not exist in "503" at line 9 (C:\wamp64\www\west\craft\app\vendor\twig\twig\lib\Twig\Template.php:436)

#0 C:\wamp64\www\west\craft\storage\runtime\compiled_templates\00\0009102817a5d89769207212bd179d422974c0400e0d4db894ad4fd45f35fd9d.php(29): Twig_Template->getContext(Array, 'global')
#1 C:\wamp64\www\west\craft\app\vendor\twig\twig\lib\Twig\Template.php(381): __TwigTemplate_37e5d62204d15e3586ae79a226d2d0e58f18084c697fef1d38e94cf3b75f8fb0->doDisplay(Array, Array)
#2 C:\wamp64\www\west\craft\app\etc\templating\BaseTemplate.php(26): Twig_Template->displayWithErrorHandling(Array, Array)
#3 C:\wamp64\www\west\craft\app\vendor\twig\twig\lib\Twig\Template.php(355): Craft\BaseTemplate->displayWithErrorHandling(Array, Array)
#4 C:\wamp64\www\west\craft\app\vendor\twig\twig\lib\Twig\Template.php(366): Twig_Template->display(Array)
#5 C:\wamp64\www\west\craft\app\vendor\twig\twig\lib\Twig\Environment.php(347): Twig_Template->render(Array)
#6 C:\wamp64\www\west\craft\app\services\TemplatesService.php(248): Twig_Environment->render('503', Array)
#7 C:\wamp64\www\west\craft\app\controllers\BaseController.php(74): Craft\TemplatesService->render('503', Array)
#8 C:\wamp64\www\west\craft\app\controllers\TemplatesController.php(200): Craft\BaseController->renderTemplate('503', Array)
#9 C:\wamp64\www\west\craft\app\framework\web\actions\CInlineAction.php(49): Craft\TemplatesController->actionRenderError()
#10 C:\wamp64\www\west\craft\app\framework\web\CController.php(308): CInlineAction->runWithParams(Array)
#11 C:\wamp64\www\west\craft\app\framework\web\CController.php(286): CController->runAction(Object(CInlineAction))
#12 C:\wamp64\www\west\craft\app\framework\web\CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#13 C:\wamp64\www\west\craft\app\framework\web\CWebApplication.php(282): CController->run('renderError')
#14 C:\wamp64\www\west\craft\app\framework\base\CErrorHandler.php(368): CWebApplication->runController('templates/rende...')
#15 C:\wamp64\www\west\craft\app\etc\errors\ErrorHandler.php(281): CErrorHandler->renderError()
#16 C:\wamp64\www\west\craft\app\framework\base\CErrorHandler.php(351): Craft\ErrorHandler->renderError()
#17 C:\wamp64\www\west\craft\app\framework\base\CErrorHandler.php(218): CErrorHandler->renderException()
#18 C:\wamp64\www\west\craft\app\etc\errors\ErrorHandler.php(145): CErrorHandler->handleException(Object(Craft\HttpException))
#19 C:\wamp64\www\west\craft\app\framework\base\CErrorHandler.php(131): Craft\ErrorHandler->handleException(Object(Craft\HttpException))
#20 C:\wamp64\www\west\craft\app\framework\base\CApplication.php(750): CErrorHandler->handle(Object(CExceptionEvent))
#21 [internal function]: CApplication->handleException(Object(Craft\HttpException))
#22 {main}

Here's the code from where the exception is thrown-

<title>        
    echo twig_escape_filter($this->env, $this->getAttribute((isset($context["global"]) ? $context["global"] : $this->getContext($context, "global")), "siteName", array()), "html", null, true);
    </title>

Template 503 -

<!doctype html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="robots" content="noindex">

    <title>{{ global.siteName }}</title>
</head>
<body style="height: 100%; margin: 0;">

    <h1 style="text-align:center; margin: 100px 0 100px;">{{ global.siteName }}</h1>

</body></html>
1
  • Does this have anything to do with database connection? Eve if I delete the database, it's showing the same error. – Amey Dahale Aug 2 '16 at 7:16
5

siteName is automatically global... you don't need to include the global. prefix.

<title>{{ siteName }}</title>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.