klirin Posted February 6, 2014 Share Posted February 6, 2014 Hello, I am not very expert in php and smarty, and I have not found a problem solution. I'm trying to use the file detector.php serves to detect browser, canvas .... http://detector.dmolsen.com/ It is best not to use {php} {/ php} within smarty. I am calling the file from productController.php with a Includer, but does not detect any variable. Alguine know how I can use detector.php? I'm going crazy. Thank you. regards Link to comment Share on other sites More sharing options...
vekia Posted February 6, 2014 Share Posted February 6, 2014 how you included this script? Link to comment Share on other sites More sharing options...
klirin Posted February 6, 2014 Author Share Posted February 6, 2014 how you included this script? include_once(dirname(__FILE__).'/detector/detector.php'); maybe i can not include a php file directly in prestashop? thank's Link to comment Share on other sites More sharing options...
vekia Posted February 6, 2014 Share Posted February 6, 2014 ok, and how you're trying to use functions of this detector ? Link to comment Share on other sites More sharing options...
klirin Posted February 6, 2014 Author Share Posted February 6, 2014 ok, and how you're trying to use functions of this detector ?I,m trying use functions in my product.tpl. Like {if $ua->canvas == "1"} {include other file.tpl} I think If the detector.php is include in the productclass.php i Can take the var directly, may be i need to pass the var from detector.php to smarty tpl too? Link to comment Share on other sites More sharing options...
vekia Posted February 6, 2014 Share Posted February 6, 2014 this is why it doesnt work. you have to pass this variable to smarty array if you will not pass it to smarty array you will not be able to use it in template files Link to comment Share on other sites More sharing options...
klirin Posted February 6, 2014 Author Share Posted February 6, 2014 Thats right. May be i cant try to do a detectorcontoller.php Thank you very very much,!!!!! Link to comment Share on other sites More sharing options...
vekia Posted February 7, 2014 Share Posted February 7, 2014 but if you include it as a php library, then you can run it in the other classes, and attach it to object variable $this->ua then you can attach it to smarty array, like other variables. Link to comment Share on other sites More sharing options...
klirin Posted February 7, 2014 Author Share Posted February 7, 2014 but if you include it as a php library, then you can run it in the other classes, and attach it to object variable $this->ua then you can attach it to smarty array, like other variables. OK! working! //Canvas detect require_once('js/Detector/Detector.php'); $this->context->smarty->assign('ua',$ua); thank's Link to comment Share on other sites More sharing options...
vekia Posted February 8, 2014 Share Posted February 8, 2014 you're welcome btw. it's great library im testing it right now and it's powerful! we can now dispaly come contents depending on user device sounds awesome i marked this thread as solved Link to comment Share on other sites More sharing options...
Recommended Posts