Topic
  • 9 replies
  • Latest Post - ‏2011-09-24T07:17:36Z by Felix_Xu
Felix_Xu
Felix_Xu
11 Posts

Pinned topic How to seperate header and footer from a single view?

‏2011-09-19T08:46:31Z |
Hi all ,I am wondering how to make header and footer seperated so that they can be shared in different views in sMash project. Thanks!
Updated on 2011-09-24T07:17:36Z at 2011-09-24T07:17:36Z by Felix_Xu
  • SystemAdmin
    SystemAdmin
    9224 Posts

    Re: How to seperate header and footer from a single view?

    ‏2011-09-19T18:33:18Z  
    Sorry Felix, this question needs more context for me to answer.
  • Felix_Xu
    Felix_Xu
    11 Posts

    Re: How to seperate header and footer from a single view?

    ‏2011-09-22T12:45:55Z  
    Sorry Felix, this question needs more context for me to answer.
    Ok,for example, I have a view called index.gt:
    <html>
    <header>
    </header>
    <body>
    </body>
    </html>

    I want to seperate it into 3 views:
    header.gt:
    <html>
    <header>
    </header>

    index.get:

    footer.gt
    </body>
    </html>

    then footer.gt and header.gt can be reused for all the views.
    I don't know how to render a view in this situation.
    Thanks for your reply!
  • Felix_Xu
    Felix_Xu
    11 Posts

    Re: How to seperate header and footer from a single view?

    ‏2011-09-22T12:46:00Z  
    Sorry Felix, this question needs more context for me to answer.
    Ok,for example, I have a view called index.gt:
    <html>
    <header>
    </header>
    <body>
    </body>
    </html>

    I want to seperate it into 3 views:
    header.gt:
    <html>
    <header>
    </header>

    index.get:

    footer.gt
    </body>
    </html>

    then footer.gt and header.gt can be reused for all the views.
    I don't know how to render a view in this situation.
    Thanks for your reply!
  • Felix_Xu
    Felix_Xu
    11 Posts

    Re: How to seperate header and footer from a single view?

    ‏2011-09-22T12:46:05Z  
    Sorry Felix, this question needs more context for me to answer.
    Ok,for example, I have a view called index.gt:
    <html>
    <header>
    </header>
    <body>
    </body>
    </html>

    I want to seperate it into 3 views:
    header.gt:
    <html>
    <header>
    </header>

    index.get:

    footer.gt
    </body>
    </html>

    then footer.gt and header.gt can be reused for all the views.
    I don't know how to render a view in this situation.
    Thanks for your reply!
  • Felix_Xu
    Felix_Xu
    11 Posts

    Re: How to seperate header and footer from a single view?

    ‏2011-09-22T12:48:21Z  
    Sorry Felix, this question needs more context for me to answer.
    Sorry,I clicked PostMessage button too many times....
  • Felix_Xu
    Felix_Xu
    11 Posts

    Re: How to seperate header and footer from a single view?

    ‏2011-09-22T12:49:22Z  
    Sorry Felix, this question needs more context for me to answer.
    There is a pair of "
    " in index.gt ... It can not be displayed here...
  • Felix_Xu
    Felix_Xu
    11 Posts

    Re: How to seperate header and footer from a single view?

    ‏2011-09-22T12:50:22Z  
    • Felix_Xu
    • ‏2011-09-22T12:49:22Z
    There is a pair of "
    " in index.gt ... It can not be displayed here...
    ... what I mean is a pair of DIV....
  • SystemAdmin
    SystemAdmin
    9224 Posts

    Re: How to seperate header and footer from a single view?

    ‏2011-09-22T16:42:40Z  
    Where you want the included template to appear, add the following to your gt file:

    <%
    request.view="head.gt"
    render()
    %>

    Subsitute the name of the gt file you want to include for head.gt. The "included" file needs to be in the app/views directory.
  • Felix_Xu
    Felix_Xu
    11 Posts

    Re: How to seperate header and footer from a single view?

    ‏2011-09-24T07:17:36Z  
    Where you want the included template to appear, add the following to your gt file:

    <%
    request.view="head.gt"
    render()
    %>

    Subsitute the name of the gt file you want to include for head.gt. The "included" file needs to be in the app/views directory.
    Got it, thanks very much!