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.

Tips tagged “Segment”

Add a {last_segment} global variable

Posted on June 28, 2010 by Erik Reagan

IMPORTANT UPDATE:
EllisLab has added an official {last_segment} tag as of EE 2.1.1. See info here: http://expressionengine.com/blog/entry/2.1.1_release_what_will_be_there_what_will_not/

—-

Sometimes it is quite handy to pull in the last segment of a URI. EE makes it easy to grab the first segment

Read this tip

Dynamically Add a Body Id (or class)

Posted on June 17, 2009 by Trevor Davis

Typically when I am creating a site, I will use an ID on the body to denote which section I am in. Then, I will also add a class of subpage to all subpages as well.

For example, a subpage may look like this:

<body id="about" class="subpage"

And the homepage would look like this:

<body id=

Read this tip

Highlight the current page in your navigation

Posted on June 08, 2009 by JonnyUK

Using the segment variables in your template, you can highlight the current page in your navigation.

For primary pages, this is pretty simple. All you need to do is check segment 1 to see if it matches up with a particular navigation item:

<ul>
<
li class="{if "{segment_1}" == ""}selected{/if}"><

Read this tip

Using URL Segments for Dynamic Navigation

Posted on June 07, 2009 by Jason Hudnutt

ExpressionEngine allows you to dynamically assign CSS navigation based on arguments passed from the URL segment.

This allows you to use CSS to display the active page based on the URL.

<a href="/about/" class="{if segment_1 == "about"}about about-active{if:else}about{/if}"></a

This is just

Read this tip

Search EE Insider Tips
Sponsored By