forked from marklogic-community/roxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Views and Layouts
dmcassel edited this page Mar 27, 2012
·
2 revisions
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 with ch:set-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