Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

separate header and footer template

edited March 2012 in Design

I have about 20 pages in my website with all the same headers and footers but different body layout. In this case, as far I can see, I have to create 20 layout templates with all identical header and footer parts. When I want to change something in the header in the future, I have then to change all 20 templates.

Is there a way to have separate header and footer templates and include them then, with by example a special tag or with php, in the page layout? That would make it a lot easier to maintain a general header and footer in the future. We could extend the php scripts ourselves to arrange that, but maybe it is already possible in a way.

Thanks, Reems


  • Before, I just used PHP in the template (since templates are compiled to PHP, PHP is valid inside any template) like this:

    <?php echo $this->render ('header', $data); ?>

    The trouble with it though was that there was no way to call a secondary file within a theme's folder, e.g., layouts/mytheme/header.html. That would always resolve to apps/myapp/views/header.html which is usually but not always what you would want.

    So I just added a new {% inc %} block that expands to the above, but also modified the way it resolves paths so that you can now use it like this:

    {% inc mytheme/header %}

    I just checked the above change into the master branch on Github, and may back-port it to the 1.1.x releases too so it makes it into Elefant 1.2 (which should be out really soon now).

    Thanks for the suggestion :)

  • Thank you very much for the quick update.:) I'm going to try that the coming days and will test this with an Artisteer template as well. If this works fine with the Artisteer template export I will make it available to the community with explanation how to use. I have already ported this template with succes to ElefantCMS. Great CMS by the way. Much easier in use then most others. Reems

  • Thanks, glad you like :) Artisteer looks interesting, more resources for designers and/or building themes would be of great benefit to other users. Cheers!

Sign In or Register to comment.