Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

MVC: Views and Layouts

Geert edited this page Jun 8, 2017 · 1 revision

Views and Layouts

Layouts

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.

Filling in a Layout

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:

  1. 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:use-view(), but in this case, the title is specific to the HTML view.)
  2. In the layout, call vh:get(): declare variable $title as xs:string? := (vh:get('title'), "New Framework Application")[1];
  3. 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.

Views

TODO