verdeandrea Posted July 14, 2015 Share Posted July 14, 2015 Hi guys, i've working on this site based on pw. I'm getting the error 324 err_empty_response in my homepage, but soon as i delete this line wire()->addHook("Page::wordLimiter", null, "wordLimiter"); everything is working fine again. This is the complete code of the hook function wordLimiter(HookEvent $event){ $field = $event->arguments[0]; // first argument $limit = $event->arguments[1]; $endstr = isset($event->arguments[2]) ? $event->arguments[2] : ' …'; $page = $event->object; // the page $str = $page->get($field); $str = strip_tags($str); if(strlen($str) <= $limit) return; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } return $event->return = $out .= $endstr; } wire()->addHook("Page::wordLimiter", null, "wordLimiter"); and is written on the top of the page. I really don't get what can cause that problem. Could you please help and suggest what can be wrong? Thanks Link to comment Share on other sites More sharing options...
netcarver Posted July 14, 2015 Share Posted July 14, 2015 Hi verdeandrea, What happens if you try this... function wordLimiter(HookEvent $event){ $field = $event->arguments[0]; // first argument $limit = $event->arguments[1]; $endstr = isset($event->arguments[2]) ? $event->arguments[2] : ' …'; $page = $event->object; // the page $str = $page->get($field); $str = strip_tags($str); if(strlen($str) <= $limit) return; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } $out .= $endstr; $event->return = $out; } ...? Link to comment Share on other sites More sharing options...
verdeandrea Posted July 15, 2015 Author Share Posted July 15, 2015 Thanks netcarver, i've tried that but it's still not working. Could it be something related to "addHook"? 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