fvsch / kirby-twig

Twig templating support for Kirby CMS 2. For Kirby 3, use https://github.com/amteich/kirby-twig
MIT License
70 stars 8 forks source link

Missing variables error in header.php #12

Closed wout closed 7 years ago

wout commented 7 years ago

Hi, I just installed this plugin and I'm getting some errors:

( ! ) Notice: Undefined variable: site in /path/to/site/snippets/header.php on line 8
Call Stack
#   Time    Memory  Function    Location
1   0.0002  242824  {main}( )   ../index.php:0
2   0.0144  973712  Kirby->launch( )    ../index.php:16
3   0.0528  3328152 Kirby\Component\Response->make( )   ../kirby.php:686
4   0.0528  3328616 Kirby->render( )    ../response.php:29
5   0.0554  3368936 Kirby->template( )  ../kirby.php:607
6   0.0554  3369120 Kirby\Plugin\Twig\TwigTemplate->render( )   ../kirby.php:619
7   0.0568  3401176 Tpl::load( )    ../TwigTemplate.php:74
8   0.0569  3422048 require( '/path/to/site/templates/default.php' )    ../tpl.php:22
9   0.0569  3422160 snippet( )  ../default.php:1
10  0.0570  3431712 Kirby\Component\Snippet->render( )  ../helpers.php:12
11  0.0579  3442984 Tpl::load( )    ../snippet.php:38
12  0.0583  3467200 require( '/path/to/site/snippets/header.php' )  ../tpl.php:22

And:

( ! ) Fatal error: Call to a member function title() on null in /path/to/site/snippets/header.php on line 8
Call Stack
#   Time    Memory  Function    Location
1   0.0002  242824  {main}( )   ../index.php:0
2   0.0144  973712  Kirby->launch( )    ../index.php:16
3   0.0528  3328152 Kirby\Component\Response->make( )   ../kirby.php:686
4   0.0528  3328616 Kirby->render( )    ../response.php:29
5   0.0554  3368936 Kirby->template( )  ../kirby.php:607
6   0.0554  3369120 Kirby\Plugin\Twig\TwigTemplate->render( )   ../kirby.php:619
7   0.0568  3401176 Tpl::load( )    ../TwigTemplate.php:74
8   0.0569  3422048 require( '/path/to/site/templates/default.php' )    ../tpl.php:22
9   0.0569  3422160 snippet( )  ../default.php:1
10  0.0570  3431712 Kirby\Component\Snippet->render( )  ../helpers.php:12
11  0.0579  3442984 Tpl::load( )    ../snippet.php:38
12  0.0583  3467200 require( '/path/to/site/snippets/header.php' )  ../tpl.php:22

The whole error output is dumped right after opening the <title> tag. After the error output nothing else is rendered.

I'm running Kirby 2.3.2 and manually installed the plugin.

fvsch commented 7 years ago

Is this while rendering a Twig template? What does your Twig code look like, and what did your PHP template look like?

wout commented 7 years ago

Not even. Just by installing and activating the plugin. It's a fresh Kirby installation with the default theme.

If you want I can put it in a private repo and make you collaborator. So you can have a look at it...

fvsch commented 7 years ago

Either that, or if you have steps to reproduce with the starterkit for instance.

wout commented 7 years ago

I'll redo the installation to see if the issue persists. Then I'll inform you about the steps to reproduction.

fvsch commented 7 years ago

Okay I could reproduce easily. I should test more before publishing 😨 Looking into it.

wout commented 7 years ago

No worries. ☺️ Let me know of I can do anything to help.

fvsch commented 7 years ago

This commit fixes the issue for me, but if you can test and confirm that it works on your setup that would be great.

wout commented 7 years ago

It does indeed fix the issue. Many thanks!