Ivan Gretsky Posted January 18, 2022 Share Posted January 18, 2022 Good day, @teppo! I have two templates (a and b) with different controllers, but same view file. So I want to make a use b's default view file in the render process. How do I do it? I tried many things like the one below in the a's controller's init() method, but without success. $this->view->setTemplate('b'); $this->view->setView('default'); For now I am doing this in views/a/default.php: <?php namespace ProcessWire; ?> <?php include($config->wireframe['paths']['views'] .'home/default.php'); ?> But maybe there is a better way? Link to comment Share on other sites More sharing options...
Zeka Posted January 18, 2022 Share Posted January 18, 2022 Hi @Ivan Gretsky That's how it works for me. In your case, you can create a controller for 'b' template that extends your 'a' template, call the parent init method and then set template for the view class PostsController extends CategoryController { public function init() { parent::init(); $this->view->setTemplate('category'); } } 2 Link to comment Share on other sites More sharing options...
teppo Posted January 18, 2022 Share Posted January 18, 2022 It should definitely work with $this->view->setTemplate(), like Zeka said above — though let me know if it doesn't, and I'll look into it ? 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