1

I use for example {{ craft.config.baseUrl }} where baseUrl is a custom variable in general.php

This works fine. But when I enable devMode it gives a template error 'craft variable unknown'.

I also get other template errors such as variable 'entry' unknown but I don't have a variable called entry in that template. These errors happen in my _layout template.

Weird thing is that with devMode false everything works fine.

I'm on mobile now but can post detailed code tomorrow if necessary.

1
  • When you say "everything works fine", have you checked the output within the HTML source? I'd venture to guess that the tags which throw errors in dev mode are simply outputting empty strings when dev mode is off.
    – Lindsey D
    Nov 6 '14 at 0:44
1

One of the things Dev Mode does is put Twig into a strict mode where it will throw an error any time a variable is referenced that isn’t defined. So that explains why you’re only getting these errors when Dev Mode is enabled. The errors should also show the part of your template code where the error occurred.

If you are certain that this is a bug, please send in a ticket from your Dashboard, including your DB backup and template files, so we can look into it.

3
  • I think I found the problem. There was an entry tag in my index.html homepage file that wasn't being used (that page didn't have a section yet). So the problem probably originated there. BUT the error it threw pointed towards my _layout.html file and always at row 30. If I deleted some rows above it, it would still point towards row 30 while the error was at the index.html file. Maybe that's a bug? The craft.config.baseUrl error is another weird thing that sometimes comes back up, allthough I double checked and everything does work fine. If I encounter it again, I'll send a bug report in! Nov 8 '14 at 9:39
  • @TomDeSmet Sounds like a bug. Can you reproduce the issue again and then send in a support ticket from your dashboard? Nov 8 '14 at 22:10
  • Bug report sent! Nov 11 '14 at 12:15
0

This looks to be a Twig bug.

By the time the Twig exception makes it to Craft's ErrorHandler, the wrong _layout.html file has already been set on the exception.

I'll try to come up with a barebones reproducible test case and create a Github issue with them.

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.