Ben

Final Tweaks…

In Assignment on May 1, 2010 at 4:06 pm

So this week I have added some extra content from a net label and sorted the navigation out. Oh and I’ve put the About page in place with nice touches!

Earth Monkey Productions
I re-purposed some of my templates and the Flash album player to stream music via the internet archive which is where all the music from Earth Monkey is stored.

Also on the Earth Monkey page I have used some CSS3 statements to create the rounded corners and text shadow effect.
I used the following in my CSS script:

Rounded Corners

-moz-border-radius: 10px;
-webkit-border-radius: 10px;

Text Shadow

text-shadow: 1px 1px 1px #666666;

Navigation

Also I have now implemented an intelligent navigation system for both the main nav and the footer nav.
It was developed after reading this very insightful tutorial

But rather than apply a class to the li tag, I used an if/else statement to add a span tag around the active menu item. Here’s the script that I used in my embedded navigation template:

<div id="nav-1">
<ul>
<li>{if '{embed:loc}' == 'home'}<a href="{site_url}" ><span>Home</span></a>{if:else}<a href="{site_url}" >Home</a>{/if}</li>
<li>{if '{embed:loc}' == 'bens'}<a href="{site_url}index.php/main-site/albums" ><span>Ben's Music</span></a>{if:else}<a href="{site_url}index.php/main-site/albums" >Ben's Music</a>{/if}</li>
<li>{if '{embed:loc}' == 'em'}<a href="{site_url}index.php/main-site/emalbums" ><span>Earth Monkey</span></a>{if:else}<a href="{site_url}index.php/main-site/emalbums" >Earth Monkey</a>{/if}</li>
<li>{if '{embed:loc}' == 'about'}<a href="{site_url}index.php/main-site/About" ><span>About</span></a>{if:else}<a href="{site_url}index.php/main-site/About" >About</a>{/if}</li>
</ul>
</div>

loc in the above script is the name of a page level variable which is assigned once at the top of each page using the expression engine script:

{assign_variable:gloc="value"}

Where “value” represents the unique name that you specify for the page. In my case I had 4 different names:

  • home
  • bens
  • em
  • about

When the main navigation and footer templates are embedded in the page, they are given the name of the page like this:

{embed="main-site/_Navigation" loc="{gloc}"}

In the above expression engine tag, the _Navigation template is given the page name by assigning the variable loc to be equal to gloc, which was declared at the top of the page.
In Expression Engine, once a variable has been declared, it can be included by using the tag parenthesis {variable_name}.

With that all place the _Navigation template then runs a series of if/else statements to determine a match for the current page. If it finds one, then it adds a span tag around the markup, which is then styled differently by CSS.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: