Zeka Posted August 1, 2016 Share Posted August 1, 2016 Hi. Im using delegate template approach and for some templates with some url segments i need to change _done.php to some another file. Is it possible via hooks or init.php? Would be appreciated for any suggestions Link to comment Share on other sites More sharing options...
Macrura Posted August 1, 2016 Share Posted August 1, 2016 Where is _done.php coming from? If you look at Ryan's CMS Critic case study, he shows how you can make an "$includeMain" variable; are you using $page->render() or wireRenderFile() for the content of your url segment pages? 1 Link to comment Share on other sites More sharing options...
Zeka Posted August 1, 2016 Author Share Posted August 1, 2016 @Macrura thanks for attention to my question. Im using almost the same sctructure as BlueVr profile. Link to comment Share on other sites More sharing options...
Macrura Posted August 1, 2016 Share Posted August 1, 2016 the profile itself has a $useDone variable, so you can also just set that to false and load your alternate file. /* * Whether to include the _done.php markup file? For example, your template * file would set it to false when generating a page for sitemap.xml * or ajax output, in order to prevent display of the main <html> document. * */ $useDone = true; in other scenarios you can stop what happens after the template by using: return $this->halt(); so therefore you could use wireRenderFile, or include/wireIncludeFile your alternate file, and then prevent loading _done by halting. 4 Link to comment Share on other sites More sharing options...
Zeka Posted August 2, 2016 Author Share Posted August 2, 2016 @Macrura thanks for point me into the right direction. By using $useDone variable i was able to do what i need. I would ask you to give some example of correct using of $this->halt(); Link to comment Share on other sites More sharing options...
Macrura Posted August 3, 2016 Share Posted August 3, 2016 depending on how your templates are configured, you could for example not have a $useDone or $useMain and then at your own discretion use the return $this->halt which should do the same thing, meaning it would prevent anything from happening after the point that you put that. 2 Link to comment Share on other sites More sharing options...
Robin S Posted August 3, 2016 Share Posted August 3, 2016 16 hours ago, Zeka said: I would ask you to give some example of correct using of $this->halt(); Ryan introduces $this->halt() in this blog post and there is some explanation in the code too. Essentially just reiterating what Macrura says above, in your template file... // some template code here: this always gets executed if(/* some test here */) { return $this->halt(); } // some more template code here: this doesn't get executed if the if() statement above is true // also, if a file is specified in $config->appendTemplateFile this is not appended 2 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