Jump to content

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.