This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
MVC: Views and Layouts
Geert edited this page Jun 8, 2017
·
1 revision
A layout is that part of the presentation layer that stays basically the same across several pages of an application. This will commonly include the header and footer and may specify the layout of what's in between. Roxy comes with a few layouts to get you started, including application.html.xqy
that mimics the layout you get from MarkLogic's App Builder.
The key part of filling in the layout is adding the page-specific view. The view and other information to be displayed is accessed through the view helper library, using the vh:get()
function. Likewise, many applications use a different HTML title for each page. Here's how to customize the title:
- In the view, set the title using
vh:set-value("title", "This is the page title")
. (This could be done in the controller withch:use-view()
, but in this case, the title is specific to the HTML view.) - In the layout, call
vh:get()
:declare variable $title as xs:string? := (vh:get('title'), "New Framework Application")[1];
- In the layout, use the title:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$title}</title>
</head>
...
</html>
Likewise, you can use this approach to populate a user login section or a sidebar.
TODO