-
Notifications
You must be signed in to change notification settings - Fork 6
Creating Templates
Spud CMS Layouts take advantage of Grails Sitemesh layout architecture. Without adding extra overhead, almost any grails layout can be used as a spud page template. By default, the default layout is 'application'. This can be changed by modifying the grails.spud.cms.defaultLayout
configuration option:
grails {
spud.cms.defaultLayout = 'my_layout'
}
By default, you will be able to edit the "Body" content of a layout which can simply be rendered in your layout using <g:pageProperty name='page.body'/>
. However, in most sites it is necessary to have multiple sections of a page defined as separately editable areas. To do this we use gsp comments to define a 'manifest' similar to how GRail's Asset Pipeline manifest works. Example:
<%
//= template_name 2 Columns
//= html Left
//= html Right
%>
...
Putting this structure at the top of your html.gsp in views/layouts
file, will inform Spud as to what content sections are available, as well as what to name this template for the user inside the admin panel. In the case of the example above, these content sections are called "Left", and "Right" respectively. This means that they can be rendered within the layout by using <g:pageProperty name="page.left"/>
, and <g:pageProperty name="page.right"/>
. The names of the content sections are rendered using content blocks and their names are converted to an underscored lowercase symbol.
Spud CMS automatically generates the meta tags necessary for your <head>
tags. It is recommended that you add the following line the the bottom of your <head>
tag:
<g:layoutHead/>
Sometimes it may be necessary to directly access the page object in your layouts. An example would be to render the page title attribute. Example:
<head>
<title>${page?.name}</title>
</head>