ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How-to include header, footer etc...

July 03, 2007 4:54am

Subscribe [1]
  • #1 / Jul 03, 2007 4:54am

    luftikus143

    22 posts

    Hi there,

    learning by doing…. and searching the docs, forum etc. ... and asking questions…

    I wonder if my thinking is somehwat correct, that if I would start a new web site design, I would (could) use a set of templates, which can include other templates.

    So, I would design a TemplateGroup with a couple of “common” parts of a web page, such as a template for header, a template for the menu, a template for the footer etc..

    Then, I would have a TemplateGroup with some main pages. And for example in the index template I would write
    {include:header}
    ....
    {include:footer}

    Is that correct? Thanks for any clarification.

  • #2 / Jul 03, 2007 5:01am

    textdriven

    107 posts

  • #3 / Jul 03, 2007 5:35am

    luftikus143

    22 posts

    Aha…. that’s interesting!

    Although, I am not sure about the importance of this one paragraph:

    The choice of whether to use an embedded template or a Template Global Variable is rather easy: if you need to use ExpressionEngine tags or PHP, then you need an embedded template.

    So, for using for example the DOCTYPE def, it makes sense to define a Global Variable. But as soon as I want to use some kind of PHP within the statement (to stay more flexible or for whatever reason), I can’t use the Global Variable, but must use en {embed}, right?

    Hmmm… slowly getting the picture.

  • #4 / Jul 03, 2007 6:10am

    luftikus143

    22 posts

    So, Derek uses

    {html_head}
    ..
    {stylesheets}
    ...
    {html_head_end}

    The sample index template had this line in the header in order to link to the css “file”:

    <link rel='stylesheet' type='text/css' media='all' href='{stylesheet={my_template_group}/site_css}' />

    which does not work if it is used in a Global Variable - due to the fact that, as described, PHP and EE Tags can’t be used within Global Variables.

    But how should it work then? Do I have to hardcode the path? That is somewhat contrary to the philosophy of EE, no?

  • #5 / Jul 03, 2007 7:24am

    silenz

    1651 posts

    You would usually put the link to the css-file together with some other constants in the <head>-section into a header-template and embed it into the main-page.

  • #6 / Jul 03, 2007 7:49am

    luftikus143

    22 posts

    You would usually put the link to the css-file together with some other constants in the <head>-section into a header-template and embed it into the main-page.

    Although I understand that, as far as I can see the example as giving above and taken from Derek’s article, uses a Global Variable for that, no?

  • #7 / Jul 03, 2007 3:33pm

    silenz

    1651 posts

    Yes, he does. And he does not use template variables in Global variables.
    So, if you want to do that you gotta embed. If not you can use Global variables.
    Those are the options to choose between depending on your requirements.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases