caribou Posted October 19, 2012 Share Posted October 19, 2012 Hello! I'm loving this CMS so far. I'd like to use a template to generate a KML file that can be included in other templates (as filename.kml, not as a dynamically generated page). Is there a way to do this? Thanks! Link to comment Share on other sites More sharing options...
ryan Posted October 19, 2012 Share Posted October 19, 2012 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 More sharing options...
caribou Posted October 20, 2012 Author Share Posted October 20, 2012 Thanks for the quick reply! I think that will do the trick, I'll try it out. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now