Jump to content
Ivan Gretsky

Using halt() within a function in template file

Recommended Posts

Good evening (at least in my part of the world)!

Is there a way to call halt() method from within a function in a template file?

Share this post


Link to post
Share on other sites

$this->halt();
As shown at the bottom of this thread.

Is this what you are referring to?

Share this post


Link to post
Share on other sites

Yes, that is what I need to do. But in a function, where $this (which contains current template) is out of scope.

Share this post


Link to post
Share on other sites

Hm... For whatever reason the halt() method is protected and can therefore only be called from within the class or derived ones. Passing $this to the function does not work and I don't know of any solution other than using die() or exit() in this case. Or just let the function return false and halt outside in that case:

function foo() {
  if(...) return false;
  echo 'foo bar';
}

if(foo() === false) return $this->halt();

echo 'something more';

 

  • Like 1

Share this post


Link to post
Share on other sites

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...