Jump to content

Generating a static KML file


caribou
 Share

Recommended Posts

Your ProcessWire template files are just like any other regular PHP file, so you can do anything with them that you could with a PHP file on it's own. Since you are wanting to generate a static KML file, your main consideration will be to determine where you generate it. ProcessWire will create a writable files directory for any page, which you can get to by accessing the filesManager() function, like this:

$path = $page->filesManager()->path();
$url = $page->filesManager()->url();

So to generate the file, you'd do something like this:

$data = "say this is your KML data";
$filename = $page->filesManager()->path . "my-data.kml";
file_put_contents($filename, $data);

Then you could access that file from your browser at:

$page->filesManager->url() . "my-data.kml";
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...