hi all,
i have been trying to find a solution to needing to trigger php code using twig (i only get the information as the form runs) and need to test it for an error 404.
curl_setopt($priv_URL, CURLOPT_RETURNTRANSFER, true);
curl_exec($priv_URL);
if(curl_getinfo($priv_URL, CURLINFO_HTTP_CODE) == 404) {
return true;
}else {
return false;
}
curl_close($prv_URL);
here is the incredibly simple way i have come up with of testing if the link creates a 404 error ( i know not 100% fool proof) so far i have tried just creating a php function like function is404check($priv_URL){ //..} and from looking on the twig website i found
$twig = new Twig_Environment($loader);
$function = new Twig_SimpleFunction('is404check', function ($priv_URL) {
//..
});
$twig->addFunction($function);
but this throws errors first at the $twig = new twig... and if i remove that, as expected at $twig->addfunction...
how do i overcome this issue in octobercms?
thanks!
Last updated