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

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
    ACCEPTED ANSWER

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

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

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

      ‏2011-09-22T12:45:55Z  in response to SystemAdmin
      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
      ACCEPTED ANSWER

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

      ‏2011-09-22T12:46:00Z  in response to SystemAdmin
      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
      ACCEPTED ANSWER

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

      ‏2011-09-22T12:46:05Z  in response to SystemAdmin
      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
      ACCEPTED ANSWER

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

      ‏2011-09-22T12:48:21Z  in response to SystemAdmin
      Sorry,I clicked PostMessage button too many times....
    • Felix_Xu
      Felix_Xu
      11 Posts
      ACCEPTED ANSWER

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

      ‏2011-09-22T12:49:22Z  in response to SystemAdmin
      There is a pair of "
      " in index.gt ... It can not be displayed here...
      • Felix_Xu
        Felix_Xu
        11 Posts
        ACCEPTED ANSWER

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

        ‏2011-09-22T12:50:22Z  in response to Felix_Xu
        ... what I mean is a pair of DIV....
  • SystemAdmin
    SystemAdmin
    9224 Posts
    ACCEPTED ANSWER

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

    ‏2011-09-22T16:42:40Z  in response to Felix_Xu
    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
      ACCEPTED ANSWER

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

      ‏2011-09-24T07:17:36Z  in response to SystemAdmin
      Got it, thanks very much!