Skip to content

Instantly share code, notes, and snippets.

@kkestell
Created April 14, 2014 18:30
Show Gist options
  • Save kkestell/10672006 to your computer and use it in GitHub Desktop.
Save kkestell/10672006 to your computer and use it in GitHub Desktop.
## Routing
Pages controller is the last entry in the routing table. Examples of routes which may be matched include:
* /Foo => Foo
* /Foo/Bar => Foo/Bar
* /Foo-Bar/Baz => Foo-Bar/Baz
### Reserved Namespaces
The following namespaces are reserved:
* /Module - Reserved for modules, e.g:
* POST /Module/Ignite/Responses - Create a new ignite survey response
* GET /Module/Auth/Log-In - Display the log-in form
Attempting to create a page in a reserved namespace should result in an error.
## PageController
The controller looks like this:
public class PageController : Controller {
public ViewResult Show(string pageName) {
// Find the page in Phoenix
var page = Grove.Core.PhoenixClient.GetPage(pageName);
// Return a 404 if the page couldn't be found
if(page == null) {
throw new HttpException(404, "Not Found");
}
// Render the page
return View(page);
}
}
## Properties of Pages
All pages must specify a URL slug, a title, and a layout.
## Page Layouts
Each layout may specify any number of widget areas. Widget area names must be unique within a given layout, but different layouts may contain widget areas with the same names.
## Rendering Pages
When rendering a page, we first enumerate all of the widgets for all of the widget areas on that page as a WidgetManifest. We pass the WidgetManifest in to the view, which looks something like this:
@if(WidgetManifest.HasWidgets("header")) {
<div id="header-widget-area">
<ul>
@foreach(var widget in WidgetManifest.GetWidgets("header")) {
<li class="widget">
@widget.Render();
</li>
}
</ul>
</div>
}
All pages are rendered using the same view, /Views/Shared/Page.cshtml, this view always inherits from /Views/Layouts/Master.cshtml
Page.cshtml contains all of the widget areas and the calls necessary to render their widgets.
Master.cshtml looks something like:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<header>
...
</header>
<article>
@RenderBody()
</article>
<footer>
...
</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment