There are cases in which you want a page to be powered by Perch Runway, but you don’t really have any editable content on the page itself. The page does not require management, but it needs to exist.
A good example for this type of pages is an XML sitemap or an RSS feed. The content in these instances are coming from Perch Runway, but the editors do not need to manage anything on the page.
Instead of setting up an editable page with nothing to edit and confusing your editors, you can take advantage of Perch Runway’s Master Pages and Routing:
A Master Page is a PHP template that defines what appears on the page.
In Runway, every type of page in your site is created as a Master Page.
Perch Runway has a front controller and you can set up routes to “point to” or display some of your pages.
Perch Runway allows you to add routes in 2 different ways:
- To an editable page (so you went to Pages on the control panel and created a new page)
- Directly to a master page
So you can add routes to a master page without adding it as an editable page in Runway. In the instance of a sitemap, you can create a master page template
perch/templates/pages/sitemap.php, which can be something as simple as:
<?php header ("Content-Type: application/xml"); ?> <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <?php perch_pages_navigation([ 'template' => 'item_in_sitemap.html', 'add-trailing-slash' => true, 'flat' => true, 'hide-extensions' => true, ]); ?> </urlset>
Then you can add the routes directly to the master page:
- navigate to Pages > Master Pages
- Select the Sitemap master page
- Add the URL pattern you want
On the edit form, add the URL pattern under “Routes”. The URL pattern in this case can be
sitemap.xml. After saving the form going to
example.com/sitemap.xml will display the contents of the sitemap master page.
If you wanted your sitemap URL to be
example.com/feeds/sitemap.xml, your URL pattern would be
feeds/sitemap.xml (note there’s no slash at the start). You can learn more about setting up your routes from the docs.