ne of the virtues of many sites recently designed by the Brighton-based creative web agency Websiteforall is that they are comprised of just one page (see for example the award-winning Love’s Restaurant). The new Websiteforall portfolio site is in that tradition, taking the visitor immediately to the heart of matters with a thumbnail list of client sites on the left and a focus on one of those sites to the right. This article explains how that setup is deployed in ExpressionEngine using a single template.
-
Sector
-
Service
Normally, pages within web sites can be classified as either single-entry or multiple-entry. Although Websiteforall is different in that all pages appear to be more or less the same, with multiple entries on the left and a single entry on the right, the key insight for deploying ExpressionEngine elegantly here was that there are indeed two types of pages, even if there appears not to be. One type is single-entry, the other is a categories listing. It’s just that seamless navigation between the two page types requires a little bit of EE magic.
The Header Title
First an overview courtesy of the EE tags within the header title:
<title>
{if segment_1 != ""}
{if segment_2 == ""}
{exp:weblog:entries weblog="clients" limit="1"
disable="categories|category_fields|custom_fields|member_data|pagination|trackbacks"}
{title} :
{/exp:weblog:entries}
{/if}
{if segment_2 != ""}
{exp:weblog:category_heading weblog="clients"}{if plural}{plural}{if:else}{category_name}{/if} : {/exp:weblog:category_heading}
{/if}
{/if}
websiteforall : creative web agency, Brighton UK
</title>
Starting with the first line, if the URL’s segment #1 is empty then we’re on the homepage and can exit the conditional. If however segment #1 does contain something then we next check whether segment #2 is empty. If it is then we’re on a single-entry page and run EE’s weblog:entries tag (with all options disabled to improve performance) to display the entry’s title followed by a colon. If however segment #2 is not empty then we’re on a categories page and run EE’s category_heading tag. These then are the three types of pages in the site: the homepage, a single-entry or a categories page.
There are two category groups, Locations and Services, but only Services get their own page, a listing of all entries with that service checked. For this to work, Use Category URL Titles In Links? is set to “Yes” and the Category URL Indicator is changed from the default “categories” to “services”.
Note that in the category_heading tag the field plural is displayed unless it’s empty, in which case the category name is displayed. The plural category field is for services that should be named differently in the plural; “logo” becomes “logos” but “web design” stays as is.
The Right Side
The title header is not the only part of the template that handles all three types of page on the site. The right side also works whether the visitor is on the homepage, a single-entry or a categories page:
{exp:weblog:entries weblog="clients" limit="1" disable="member_data|pagination|trackbacks" url_title="{segment_3}" }
<div class="container">
<div class="clientid">
<h1>{if clients_url}<a target="_blank" href="http://{clients_url}">{/if}{title}{if clients_url}</a>{/if}</h1>
</div>
<div class="rightclient">
<div class="clientinfo">
<p>{if clients_business}{clients_business}, {/if}{categories show="not 16|17|22" show_group="3" backspace="1"}{category_name}, {/categories}</p>
{if clients_url}<a target="_blank" href="http://{clients_url}">{clients_url}</a>{/if}
</div>
{if clients_testimonial}
<div class="clienttestimonial">
<p><img src="{site_url}img/quoteopen.png" width="22" />{clients_testimonial}<img src="{site_url}img/quoteclose.png" width="22" /></p>
<p class="client-name">{if clients_url}<a target="_blank" href="http://{clients_url}">{/if}{clients_author}{if clients_url}</a>{/if}</p>
</div><!-- /clienttestimonial -->
{/if}
<div class="services">
<h3>what we did for {title}</h3>
<p>{categories show="not 4|6|50|53" show_group="1" backspace="1"}{if segment_2 != category_url_title}<a href="{path=/}{if segment_3 ==">{/if}{category_name}{if segment_2 != category_url_title}</a>{/if}, {/categories}</p>
</div>
<div class="clientbranding">
<div class="selector">
{if clients_logo && clients_business_card}
<ul id="branding" class="shadetabs">
{if clients_logo}<li><a href="#" rel="logo" class="selected">logo</a></li>{/if}
{if clients_business_card}<li><a href="#" rel="businesscard">business card</a></li>{/if}
</ul>
{/if}
</div>
{if clients_logo}<div id="logo"><img src="{clients_logo}" width="240" /></div>{/if}
{if clients_business_card}<div id="businesscard"><img src="{clients_business_card}" width="240" /></div>{/if}
</div>
</div><!-- /rightclient -->
{if clients_screenshot}
<div class="screen">
{if clients_url}
<a target="_blank" href="http://{clients_url}">{/if}<img src="{clients_screenshot}" width="340" border="0" />{if clients_url}</a>
{/if}
</div>
{/if}
</div><!-- /container -->
{/exp:weblog:entries}
This is where the magic is — in the parameters of the weblog:entries tag. The url_title parameter is set to contain the contents of segment #3. This of course only works if we indeed have a segment #3, that is, if we’re on a services page. Service pages always have a fixed URL structure: segment #1 is “services”, segment #2 is the url_title of the particular service, and segment #3 is the url_title of the client to feature on the right. But what if there is no segment #3? The url_title parameter is empty, therefore ignored, and the tag falls back to its default behavior, which is to treat the final segment in the URL as the url_title. If we have a segment #1 then we’re on a single-entry page and the entry corresponding to the url_title in segment #1 is displayed. If however segment #1 is also empty, then the limit parameter ensures that only one client is featured on the right, that is, the latest one — or any that is set as sticky.
Most of the remaining conditionals in the right side simply control whether to display various fields — logo, business card, screenshot, url — depending on whether they are empty for this particular entry. Both services (category group 1) and locations (category group 3) are displayed with hardcoded suppression of their top-level categories.
Under “what we did”, the entry’s services are displayed using the categories tag. If the service’s url_title appears in segment #2 of the URL — that is, if we’re on the service’s own page — then there is no link to it. Because we’re within the categories tag, EE automatically adds segments #1 and #2 to any links, with segment #1 being the reserved Category URL Indicator (“services”) and segment #2 the category’s url_title. Within the conditional is another that tests whether to set the link’s segment #3 as the contents of the current URL’s segment #1 if the current page is a single-entry one or as the current URL’s segment #3 if we’re on a services page.
The Left Side
The left side is quite different depending on our current page type.
{if segment_2 == ""}
<h1>our clients</h1>
<div class="selectorclient">
<ul id="clients" class="shadetabs">
<li><a href="#" rel="uk" class="selected">UK</a></li>
<li><a href="#" rel="france">France</a></li>
<li><a href="#" rel="belgium">Belgium</a></li>
</ul>
</div>
<div id="uk">
<ul class="thumb">
{exp:weblog:entries weblog="clients" dynamic="off" category="16" limit="99" orderby="title" sort="asc" sticky="off"}
<li {switch="||class='last'"}>{if segment_1 != url_title}<a href="{path=/}{url_title}">{/if}<img src="{clients_thumbnail}" alt="{title}" border="0" />{title}{if segment_1 != url_title}</a>{/if}</li>
{/exp:weblog:entries}
</ul>
</div>
<div id="france">
<ul class="thumb">
{exp:weblog:entries weblog="clients" dynamic="off" category="17" limit="99" orderby="title" sort="asc" sticky="off"}
<li {switch="||class='last'"}>{if segment_1 != url_title}<a href="{path=/}{url_title}">{/if}<img src="{clients_thumbnail}" alt="{title}" border="0" />{title}{if segment_1 != url_title}</a>{/if}</li>
{/exp:weblog:entries}
</ul>
</div>
<div id="belgium">
<ul class="thumb">
{exp:weblog:entries weblog="clients" dynamic="off" category="22" limit="99" orderby="title" sort="asc" sticky="off"}
<li {switch="||class='last'"}>{if segment_1 != url_title}<a href="{path=/}{url_title}">{/if}<img src="{clients_thumbnail}" alt="{title}" border="0" />{title}{if segment_1 != url_title}</a>{/if}</li>
{/exp:weblog:entries}
</ul>
</div>
{/if}
If segment #2 is empty — that is, if we’re on the homepage or a single-entry page, then we display our clients by country. Since it’s unlikely that Websiteforall will spread to dozens more countries in the very near future, country listings are handled only semi-automatically in that each has its own weblog:entries tag filtered using the category parameter with that particular country’s category_id hardcoded in (we can’t use EE’s out-the-box category_archives tag because it doesn’t handle custom fields). If the number of countries suddenly explodes we can automate things by looping through all the entries in the country category group and within that loop embed each one’s weblog:entries tag in a sub-template — though then we could no longer claim a single-template deployment.
If segment #2 is not empty and — just to double-check — segment #1 is “services”, then we’re on a categories page:
{if segment_1 =="services"}
<h1><a href="{path=/}{segment_3}">our clients</a> / {exp:weblog:category_heading weblog="clients"}{if plural}{plural}{if:else}{category_name}{/if}{/exp:weblog:category_heading}</h1>
<div id="uk">
<ul class="thumb">
{exp:weblog:entries weblog="clients" orderby="title" sort="asc"
disable="member_data|pagination|trackbacks" sticky="off"}
<li {switch="||class='last'"}><a href="{path=/}services/{segment_2}/{url_title}"><img src="{if segment_2 == " alt="{title}" border="0" />{title}</a></li>
{/exp:weblog:entries}
</ul>
</div>
{/if}
Here the word “our clients” in the h1 is now a link to a single-entry client page. We bring along into segment #1 the magic ingredient: the entry currently in segment #3 and displayed on the right. So upon clicking here the left side will change from the current category to a list of clients, but the right side will stay the same, providing continuity.
If we haven’t clicked and are still here, next is the category_heading tag to display the current service, with the conditional for the plural field just like in the header title.
The next tag is weblog:entries which, because we’re on a categories page, only displays entries in our category.
For both single-entry and services pages, the switch tag enables every third thumbnail to get a class of “last”, thereby enabling three columns, and the conditional that tests whether segment #1 differs from the url_title ensures that a page does not link to itself.
Services Menu
An EE tag is used in one final place on the template: to display the menu of services:
<div id="navi2">
{exp:weblog:categories style="nested" weblog="clients" category_group="1"}
{if segment_2 != category_url_title}<a href="{path=/}">{/if}{category_name}{if segment_2 != category_url_title}</a>{/if}
{/exp:weblog:categories}
</div><!-- /navi2 -->
The list is spread across four columns using CSS.
Conclusion
We didn’t set out to build the site in conformity with how ExpressionEngine’s categories work. Instead, the things Stephen wanted for the site dovetailed with EE’s natural setup.
Tue 27 Sep ’11
7:32am
reer
mbt shoes sale
mbt sandals
there are so cheap. Buy MBT Shoes in UK Online Store enjoy on sale prices.
Fri 14 Oct ’11
11:12am
pearlcarbajal
This blog makes me realize the energy of words and pictures. As always your things are just gorgeous and I am grateful that you let us look in! Keep coming up with ideas.
Thu 5 Jan ’12
5:51pm
Albrt003
This is cool!
There are many ways to improve your cooking skills: reading great cookbooks, taking cooking classes and good old fashioned practice in the kitchen are traditional methods. But these days, online cooking recipe videos are another excellent resource for aspiring chefs.
Here’s how to get the most from the cooking videos you encounter.
1. Cake can be divided into five basic types - yeast cakes, cheesecakes, butter cakes, sponge cakes and boxed cakes. Find out how to make these great cake recipes at http://everything-cake.com
2. At http://milkdelight.com you will find almost all types of milk recipes prepared by using different types of milk whether condensed or low-fat or kefir or coconut or soy!
3. There are a lot of different ways of preparing fish. You’ll find out more of video tutorials at http://fishlogy.com People who like cooked fish have all the more options with them. They can steam, fry, bake, grill, poach and broil fish to enhance its flavor.
4. Have you ever been curious on how to make delicious soups? Now is the right time to make one just watch the videos and follow list of soup recipes at http://soupssimo.com
5. Most people like to eat fresh peas with spearmint and butter. Pepper and salt is also added to make it taste good. Care to know more about Peas Dishes, Recipes and Varieties? Check out http://aboutpeas.com
6. For banana lovers, here’s a cool http://bananapedia.com site where you can watch different video recipes and you could simply apply them. Have fun!
7. There are limitless ways of cooking chicken. This http://wikichicken.com site shares a lot of chicken recipes and the most popular chicken dishes.
8. To see the best sampling of meat dishes popular throughout the world visit http://allthemeat.com
9. Cooking and baking bread play essential role in coffee shops. Find out how they are made at http://everything-bread.com
10. Learn on how you can try some of coffee recipes with a free coffee recipe video http://coffeefashion.com
11. Here is how to make some delicious pizzas at home, Pizza dough, pizza sauce, pizza toppings and pizza pies http://learnaboutpizza.com
12. For a staggering number of people, chocolate occupies a major part of their lives. They sleep chocolate, breathe chocolate, and talk chocolate and what not! This site http://chocolarious.com is dedicated to all such chocolaty people like you!!
13. Become aware of many useful products lemons can give; http://everythinglemon.com
14. Variety of salad recipes can be found on the http://thesaladsite.com These sites inform about the types of salads, their recipes and dressings.
15. As of today, a cocktail is a lovely drink that contains at least one type of spirit and at least one type of mixer (fruit juice or soda). More about cocktail at http://cocktails.com
16. Corn was acknowledged as a rich nutritional resource a thousand years ago. Check http://everything-corn.com/ for corn products and dishes plus corn video recipes!
17. Here is a collection of the best of the beef recipes ever. http://ibeefrecipes.com/
18. Pepper recipes are as abundant as there are types of peppers – more info at http://pepperecipes.com/
19. http://allthemeat.com/ is where you can find great video recipes, meat dishes, methods of meat preparation etc.
20. http://lifestyle.gourmandia.com - Collection of recipe videos by michelin chefs and social network for gourmands.
21. http://blog.gourmetrecipe.com, http://blog.gourmandia.com - Blog on contest, cooking, health and life, heartbeat, nutrition, recipes, restaurants and travel
22. http://blog.xdestination.com - Blog on travel destination, festivals and cities worldwide.
23. http://heartbeat.gourmetrecipe.com - Gourmets networking sharing Recipes, Food tips, and art of the table.
24. http://www.gourmetrecipe.com - Gourmet Recipe is the place to find the tastiest, healthiest gourmet recipes. Watch videos of great chefs preparing meals, find easy beginner dishes, and more.
25. http://www.xdestination.com - xDestination is the place to go before you travel. Watch videos of popular travel destinations around the world, find the best hotels and restaurants, and more.
26. http://foodiamond.com - Foodiamond is a website that caters to those who love to both eat and prepare fine food. Whether you’re a novice cook or you know your way around the kitchen quite well, you’re sure to find something that suits your tastes on Foodiamond.
27. http://www.gourmet-pass.com - At Restaurant Gourmet-pass, we offer fast and efficient delivery services from popular Ottawa take-out restaurants.
28. http://www.goctest.ca - Practice public service exams to prepare for public service commission jobs. Government of Canada and Public Service Commission Practice exams and interview preparation.
29. http://www.thestudentbiz.com - StudentBiz is your one stop resource for buying, selling, or exchanging textbooks and other goods directly on your own campus. Regardless of your year, faculty, or program we you’re able to find someone from your own University to make an exchange with.
30. http://www.vu247.com - Whether you are at home or on the move to a familiar or unfamiliar destination, you will find everything you need to know aboutwhat’s happening in the world, right here, right now!... well, eventually. This is where you come in. Upload any of your events to vu247.com with ease and share your event(s) with the planet.
31. http://www.fondnessmedia.com - With more than ten million website visitors per month, Fondness Media provides a unique opportunity to the advertisers and publishers that would like to expand their reach in a targeted way. We combine the power of the internet and mobile communication.
32. http://heartbeat.gourmetrecipe.com - Gourmets networking sharing Recipes, Food tips, and art of the table.
33. http://www.gourmandia.com - Gourmandia is a culinary website offering videos of world-class Michelin rated chefs exhibiting their techniques. Also features documentaries on fine dining restaurant locations and cities, recipes, forum, and more.
Thu 5 Jan ’12
6:06pm
Stimer03
yah, thanks for sharing!
Mon 20 Feb ’12
3:57pm
Craks
Do you think realistically integrate keygen download this update to the site?ontest, cooking, health and life, heartbeat, nutrition, recipes, restaurants and travel
Tue 6 Mar ’12
3:47pm
coffre fort fichet bauche
Dont talk about espionage.Hands on a bale of White.Steve is one cool guy.Dannos gonna tell you why.
Wed 4 Apr ’12
4:39pm
Boise
Good. Thanks for sharing Trey www.BuildIdaho.com
Tue 23 Apr ’13
6:13am
Robert Cuke
http://www.mylogoimprinted.com
Tue 23 Apr ’13
6:14am
Robert Cuke
Anillos de Compromiso
Alianzas de diamantes
colgantes de diamantes
promotional pens
Fri 16 Sep ’11
2:05pm
Josh
Wow, thanks for just giving away this code. The other day when I was babysitting I was trying to show Ernest how to help me with coding and I came upon this. Although it’s still a little too complex for him, I thank you for just giving it away.