I am writing a new Grails application which uses the website template Admintasia. Part of the layout gsp file has a section for the header and sub-header. For this to be used, I needed to be able to pass those two strings from the view to the layout.
Here's what my view looks like:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta name="layout" content="admintasia"/> | |
<meta name="pageHeader" content="This is a test" /> | |
<meta name="pageSubHeader" content="blah blah blah" /> | |
</head> | |
<body> | |
... |
And here's what my layout looks like:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2><g:pageProperty name="meta.pageHeader" default="MISSING PAGE HEADER" /></h2> | |
<h4><g:pageProperty name="meta.pageSubHeader" default="" /></h4> |
I hope this helps out!
This comment has been removed by the author.
ReplyDeleteI bought this template but it seems more tailored for PHP. How do you use it in grails? Do you have an application sample which uses it, you could share
ReplyDeleteThanks
Pascal
Oh thanks.. this is exactly what I was looking for.. I'm using this to send a custom classname to the body of the page.
ReplyDeletein the view: (brackets removed)
meta name="pageName" content="home index"
in the layout file: (brackets removed)
body class="one_col ${g.pageProperty(name: 'meta.pageName')}"
works great!