diff --git a/Template.md b/Template.md new file mode 100644 index 0000000..5c3632e --- /dev/null +++ b/Template.md @@ -0,0 +1,108 @@ +## TileServer-PHP: Custom look&feel with a template + +TileServer-PHP project uses TileViewer for the frontend. TileViewer shows several sample web viewers for the most popular JavaScript libraries such as Google Maps API, OpenLayers or Leaflet. In TileViewer there are also tutorials, embed links, guides for the GIS software on desktop, etc. + +The user of the TileServer-PHP project can replace this default frontend with a different one - using a custom template. +The tileserver may then get a completely different branding and look&feel for the online visitors. + +The custom template is a separate HTML or PHP file - linked from the main tileserver.php script. + +There are several PHP variables available for use in the template: + - `$baseUrls` - array with URLs to server + - `$serverTitle` - string with name of server from config + - `$maps` - array with metadata about each layer + +To start to use the template user should uncomment [line 13](https://github.com/klokantech/tileserver-php/blob/master/tileserver.php#L13) in the tileserver.php file and set a correct template filename e.g. `$config['template'] = 'template.php'`. If server runs in docker, the path to the environment variable could be used instead. + +A sample template file showing Leaflet application with a layer switcher listing all layers in TileServer-PHP is available at: +``` php + + +
+ + + + +