Nico Knoll Posted August 28, 2014 Share Posted August 28, 2014 Hey, I would love to have something like $config->defaultTemplateFile in the config.php. What it should do: If set to "true" every template (except admin of course) should use the defined template file instead of its own. If you want to use another file (or the default file like page.php for page) you have to define it as "alternate template filename". Advantage: It's great if you're using a ajax driven site if you don't have to set every template to use e.g. "main.php" or "app.php" or whatever. What do you guys think? -- Nico 3 Link to comment Share on other sites More sharing options...
teppo Posted August 28, 2014 Share Posted August 28, 2014 +11. Nope, not a typo -- just how much I want this to happen. I'm not much of a fan of AJAX driven sites, but I do tend to implement template level front controller pattern to all the sites I work on. Being able to route all requests to specific file without having to define that file separately to each and every template as an alternate template file would be very, very nice addition. 3 Link to comment Share on other sites More sharing options...
Nico Knoll Posted August 28, 2014 Author Share Posted August 28, 2014 Shouldn't be that hard to implement I guess. Link to comment Share on other sites More sharing options...
Soma Posted August 28, 2014 Share Posted August 28, 2014 public function ready(){ if(wire("page")->template == "admin") return; wire("page")->template = "ajax"; } done. Not sure about consequences. Page viewable is set by if template exists or not. 3 Link to comment Share on other sites More sharing options...
Nico Knoll Posted August 28, 2014 Author Share Posted August 28, 2014 But doesn't it has to be an autoload module then? Link to comment Share on other sites More sharing options...
ryan Posted November 2, 2014 Share Posted November 2, 2014 Nico, I like what you are getting at, but think an option like that might be a source of confusion because it would change the entire way that templates work, as well as the way that viewability is determined. Most likely this would be problematic for PW's internal templates and logic. What I would suggest instead is repurposing of the existing $config->appendTemplateFile option and letting that serve is your defaultTemplateFile. In order to make sure that PW considers your page viewable, you'd still have to have a file for the template, but it could be completely blank. While I'd prefer the method mentioned above, another alternative would be to automatically populate the altFilename property of every template that you wanted to behave this way. For example, in your /site/templates/admin.php file you could add something like this: foreach($templates as $template) { if($template->flags & Template::flagSystem) continue; if($template->filenameExists()) continue; $template->altFilename = 'ajax.php'; $template->save(); } 4 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