Jump to content

Smarty Display Function


dimitri320

Recommended Posts

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!!!!!!

Link to comment
https://forums.phpfreaks.com/topic/191896-smarty-display-function/
Share on other sites

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.

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);

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.