Hi,
I’m developing my site and I’m trying to cut down on repetition. I will explain and hopefully there’s a simple solution.
Like most people I’m splitting the front-end templates pages into shared components in the form of EE templates like so:
{embed="site/.head" document_title="{document_title}" section_id="{section_id}" document_classes="{document_classes}"}
{embed="site/.header"}
CENTRAL CONTENT BLOCK - template mark-up and content goes here
{embed="site/.footer"}However I don’t want to have to repeat this block of code across potentially hundreds of templates because should I wish to add a new embed variable to the head template I’d have to update it across all templates that used it.
I’d like one template that dynamically includes the “central content block”, something like:
{if segment_1 == ""}
{preload_replace:document_title="Airfront Media Ltd — Front-end Development & Creative Design"}
{preload_replace:section_id="home"}
{preload_replace:document_classes="index"}
{if:elseif segment_1 == "work"}
{preload_replace:document_title="Airfront Media — Work & Portfolio"}
{preload_replace:section_id="work"}
{preload_replace:document_classes="index"}
{/if}
{embed="site/.head" document_title="{document_title}" section_id="{section_id}" document_classes="{document_classes}"}
{embed="site/.header"}
{embed="{section_id}/index"}<!-- central content block -->
{embed="site/.footer"}I’ve tried this but because the template group “work” exists, it just loads that template without the surrounding pieces.
I’m hoping by now, if you’ve been so kind and read this far, you’ve got my gist and can make some suggestions as to where I’m going wrong if you have any suggestions.
Cheers,
- Paul.