Published by Mijingo

tips icon image

EE Insider Tips
Sponsored by Mijingo's EE 2 Screencasts

ExpressionEngine mini-howtos created by the EE Insider community.

Use a single template for multiple pages

User's avatar
  • Posted by Andy Harris
  • June 09, 2009
  • 2 people have found this tip helpful.

On most of our sites we have many pages that are exactly the same, using the same weblog where only the content is different.

In cases like these, I create a single template along these lines:

{assign_variable:weblog="{embed:weblog}"}
{exp
:weblog:entries weblog="{weblog}" disable="categories|category_fields|member_data|pagination|trackbacks"}

<body id="{weblog}">

<
div id="main">
    <
h1>{title}</h1>
    
{custom_fields etc}
</div>


{html_close}
{
/exp:weblog:entries} 

My about page and contact page would then simply call this template as an embed, passing in their weblog names:

About page:

{embed="includes/_template_main" weblog="about"

Contact page:

{embed="includes/_template_main" weblog="contact"

This enables me to use a single template for all pages of this type, whilst retaining the flexibility to change the template if required.

Add Your Comment?

You must have an EE Insider account to post comments on Insider Tips. It's fast, easy and hassle-free.

Sign up now (or login).

Search EE Insider Tips
Sponsored By