dimitri320 Posted February 12, 2010 Share Posted February 12, 2010 How it is possible to use the display() function and display templates which are located on some other server, for instance at www.some-domain.com/templates/index.tpl. When loading templates from anywhere on the host server then we do: &smarty->display("file:usr/local/....index.tpl") Is there something like file: when loading templates from outside your host server?? Thanks!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/191896-smarty-display-function/ Share on other sites More sharing options...
premiso Posted February 12, 2010 Share Posted February 12, 2010 Is there a reason you do not just download the remote template file and save it to your server to access from there? Quote Link to comment https://forums.phpfreaks.com/topic/191896-smarty-display-function/#findComment-1011465 Share on other sites More sharing options...
dimitri320 Posted February 12, 2010 Author Share Posted February 12, 2010 No really, it's the exact opposite, I'm sending my templates out, and leaving the PHP on my server and need to access the templates on the remote server. It's for development purposes. Quote Link to comment https://forums.phpfreaks.com/topic/191896-smarty-display-function/#findComment-1011473 Share on other sites More sharing options...
premiso Posted February 12, 2010 Share Posted February 12, 2010 Well the only way I could think of doing this with smarty, is you either need to pass it as a string (so use file_get_contents or cURL) to retrieve the data or write the file to a file on your server. Which can be done with the fopen functions coupled with file_get_contents / cURL. I do think you can pass a string to Smarty to parse but I am unsure how to do that and would referrer you to the Smarty Forums / Documentation. Quote Link to comment https://forums.phpfreaks.com/topic/191896-smarty-display-function/#findComment-1011474 Share on other sites More sharing options...
dimitri320 Posted February 13, 2010 Author Share Posted February 13, 2010 Thanks a lot, it works like a charm, here's the code in case you'll ever need to have such a setup: $resource_name_url = 'http://www.yourdomain.com/'; $file_contents = file_get_contents($resource_name_url.$resource_name); $path = 'C:/www/YourProject/'.$resource_name; $fh = fopen($path, 'w+') or die("can't open file"); $stringData = $file_contents; fwrite($fh, $stringData) or die("cant't write to file"); fclose($fh); Quote Link to comment https://forums.phpfreaks.com/topic/191896-smarty-display-function/#findComment-1011754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.