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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...