How Can I Stop Script Execution From A Hook

Hi,

I'm using a hook in my addon that in one case displays a notification using “fn_set_notification” and it is supposed to stop execution after this because in this case there is an error with the entered data.

So right now I'm just using exit; after the notification and it is working fine but it generates the following error:


PHP Fatal error: Uncaught --> Smarty: Missing template name <--
thrown in /path//to/public_html/app/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php on line 679




So I guess the controller is returned to the templater which doesn't have a template to show or whatever.

How can I do this the right way?

Redirect to the page of your choice.

Redirect to the page of your choice.

It is an AJAX request.

Please provide us with the code which is executed before exit function

Please provide us with the code which is executed before exit function

if (!preg_match('/\S+/', $request_data['new_name']) && defined('AJAX_REQUEST')) {
					$msg = 'Please fill in your new name value.';
					fn_set_notification('E', fn_get_lang_var('error'), $msg, 'I', 'empty_name');
					exit;
				}

Hm.. I do not see any reason for the mentioned error. Try to remove the check of the ajax error and run the URL directly in the browser

Hm.. I do not see any reason for the mentioned error. Try to remove the check of the ajax error and run the URL directly in the browser

Didn't help .... I discovered a strange thing now though, it is that I use the same code for 3 conditions in the same hook and none of the other two produce the error it is only this one and more interestingly I tried changing the order of the three conditions and I found that the error is always produced by the last condition no matter which one of them it is.

Thoughts?

Thoughts?

No thoughts from me without detailed code examination. Sorry

No thoughts from me without detailed code examination. Sorry

No problem I can provide the code just tell me what you need. :)

I have seen that error in the past at different client sites (mostly V 4.2.x). I'd always just assumed that something was continuing on from a POST when it should have redirected because I don't think the templater is initialized on a POST request. However, I've never been able to track it down because it seemed inconsistent without adding diagnostic info into the templater to see the call stack.

Hi guys i have the same problem. any idea how to fix this? i get the followin error in error logs:

[12-Jan-2016 17:06:53 Europe/Istanbul] PHP Fatal error: Uncaught --> Smarty: Missing template name <--

thrown in /home/name/public_html/app/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php on line 679