Zeka Posted January 14, 2018 Share Posted January 14, 2018 Hi. Not sure that it's important but here is my setup: // site/init.php wire()->addHookBefore('PageRender::renderPage', function (HookEvent $e) { /** @var Page $page */ /** @var HookEvent $event */ /** @var Template $template */ $event = $e->arguments(0); $options = $event->arguments(0); $page = $event->object; $template = $page->template; $options['prependFiles'] = [ "{$template}.routes.php", "_init.php", ]; $options['appendFiles'] = [ "layouts/_main.php", ]; $event->setArgument(0, $options); }); // site/templates/_init.php $view = new \stdClass(); $this->wire('v', $view, true); // site/templates/someteplate.php bd($v) ---> null bd(wire('v')); ---> stdClass So I'm confused why I can't directly access API variable through $v variable in this case but able through wire('v')? But if I move code from "site/templates/_init.php" to "site/init.php" it is accessible through $v in templates files. Is it normal behavior? Link to comment Share on other sites More sharing options...
Zeka Posted January 23, 2018 Author Share Posted January 23, 2018 Bump Link to comment Share on other sites More sharing options...
Soma Posted January 23, 2018 Share Posted January 23, 2018 Yes is normal. _init.php the page is already rendering and the APi vars are extracted. 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now