Friday, October 8, 2010

Passing Data From View to Layout via pageProperty

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:

And here's what my layout looks like:

I hope this helps out!

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I 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

    Thanks

    Pascal

    ReplyDelete
  3. 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.

    in 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!

    ReplyDelete