Usage Examples - Surge-ee/SurgeEO GitHub Wiki

Here are some of the many ways you can use this add-on in your templates!

When it comes to templates, ExpressionEngine's flexibility means there are many ways to accomplish any goal. A direct result of this is that there are a few ways you can use SurgeEO.

First, we suggest using embeds or snippets to include your site header in your templates.

Example Header Template site.group/_header.html:

<!DOCTYPE html>
<html>
    <head>
	<title>{embed:title}</title>
	<meta name="keywords" content="{embed:keywords}" />
	<meta name="description" content="{embed:description}" />
    </head>

Here we have a basic header template which we can use in other templates. It contains the opening, needed html and three embed variables. There are Title, Keywords and Description. Next we'll see how to pass those embed variables into the header template.

Example Generic Template site/template.html - Using URL Segments

{embed="site/_header"
	title="{exp:surgeeo:title url_title='{segment_3}'}"
	keywords="{exp:surgeeo:keywords url_title='{segment_3}'}"
	description="{exp:surgeeo:description url_title='{segment_3}'}"
}
<body>
	<div class="container">
		<div class="row">
			{exp:channel:entries channel="some_channel" limit="1"}
			<article>
				<h2>{title}</h2>
				{content}
			</article>
			{/exp:channel:entrie}
		</div>
	</div>
</body>

The first line of this template includes our header embed. We are then passing it the three embed variables (title, keywords, description). These will pass values so the {embed:title}, {embed:keywords} & {embed:description} variables work inside of site.group/_header.html.

This method uses the URL Segment to get the articles URL Title. You must define which segment the URL title will be in.

If you are using SurgeEO's awesome Pages functionality

You might be using SurgeEO's Pages if you are listing multiple entries on a page, or don't have a URL Title available to you.

{embed="site/_header"
	title="{exp:surgeeo:page_title}"
	keywords="{exp:surgeeo:page_keywords}"
	description="{exp:surgeeo:page_description}"
}
<body>
	<div class="container">
		<div class="row">
			{exp:channel:entries channel="some_channel"}
			<article>
				<h2>{title}</h2>
				{content}
			</article>
			{/exp:channel:entrie}
		</div>
	</div>
</body>

The header embed does not need to change in this instance. However, you'll need to changes the add-on tags you use.

Use Cases:

  1. Entry: Within Loop
  2. Entry: Using Query Module
  3. Page: On a page
  4. Page: Same template for multiple pages (any different?)
  5. Using global header embed
  6. Putting tags in global header, vs in specific template
  7. Split header up for page sections?
  8. Prepend/Append over-ride
  9. Fallback
⚠️ **GitHub.com Fallback** ⚠️