Jump to content

Recommended Posts

Posted

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

Posted

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?

  • Like 1
Posted

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.

  • Like 4
Posted

@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();

Posted

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.

  • Like 2
Posted
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

 

  • Like 2

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...