One Of Us Creative Writing Website. "Use the web to help your creative writing."

 

Page 4 of 5 pages for this article « First  <  2 3 4 5 >

How I Built One Of Us with Expression Engine

Breadcrumbs

The breadcrumbs are the standard static pages module breadcrumb trail code.

Left hand menu

This is the second example of using the

{if} 

statement and the first one that allows me to manage multiple site sections from one template.

{if seg_1 == "writing_tips"}
{exp
:static_page_path direction="post" page="6"}<a href="{url_title}" title="Click to visit the {title} page.">{title}</a>{/exp:static_page_path} 
{
/if}
{if seg_1 
== "features"}
{exp
:static_page_path direction="post" page="7"}<a href="{url_title}" title="Click to visit the {title} page.">{title}</a>{/exp:static_page_path} 
{
/if}
{if seg_1 
== "articles"}
{exp
:static_page_path direction="post" page="8"}<a href="{url_title}" title="Click to visit the {title} page.">{title}</a>{/exp:static_page_path} 
{
/if}
{if seg_1 
== "writing_resources"}
{exp
:static_page_path direction="post" page="15"}<a href="{url_title}" title="Click to visit the {title} page.">{title}</a>{/exp:static_page_path} 
{
/if}
{if seg_1 
== "news"}
{exp
:static_page_path direction="post" page="14"}<a href="{url_title}" title="Click to visit the {title} page.">{title}</a>{/exp:static_page_path} 
{
/if} 

The

{exp:static_page_path direction="post" page="6"
part of this code is the navigation generation code from the static pages module. The page=”6” part tells EE which page in the hierarchy it should display the children of. Page 6 is the ID of the writing tips page so this tells EE to show all of this page’s children.
{url_title} 
is simply the url of the page and
{title} 

is the name of the page.

The

{if} 

conditionals work in the same way as the navbar. They look to see which section you are in by checking the name of segment 1 and displays the correct code. The only difference in each piece of code is the page ID number. You can see the different left hand menus in the image below. Remember, that each page uses the same code for the menu:

Click on the image to view a larger version.
Different left hand menus in different sections

Content

Everything between the:

{exp:weblog:entries category="{static_page}" dynamic="off" weblog="content" status="static"

and the:

{/exp:weblog:entries} 

tags consists of the weblog entry. Basically this means that the content that I enter into the fields from my edit page (including custom fields) can be displayed here simply by writing out its name within curly tags such as

{recommended} 

for example.

Whoops

The first mistake that I made when I built the template was to put the start and closing tags above at the beginning and end of my HTML template. I thought I had to do this to get any EE tag to work but I was wrong. You only need to put the weblog:entries tag around any part of the page that is populated from the fields on the edit page. If you put the weblog:entries tag around everything, then other EE tags won’t work properly (the breadcrumbs for the static pages module wouldn’t render for me).

Conditional variables

Another example of the wonderful

{if} 

conditional came about whilst I was browsing through the documentation and discovered conditional variables.

{if recommended != ""}
<div id="boxout">

<
h2>Recommended</h2>
{recommended}
</div>{/if} 

All this does is checks to see if the “recommended” field has been completed and if so, render the code for the box-out that contains the recommended tag.

This was perfect for me as I had decided to launch the site before I had completed putting the supplementary content into it. Previously I had empty box-out areas with the “recommended” heading in it and no content. This didn’t look good at all and this solution simply removed those box-out areas if I hadn’t places any content into them. Here are two pages, one with content in the “recommended” box and one without:

Click on the image to view a larger version.
Pages with and without the recommended box

Allow EE code

As stated earlier, I wanted to be able to use EE code in the content of my page and this code allowed me to do this (remember to install the plug-in to let you do this):

{exp:allow_eecode}
{body}
{
/exp:allow_eecode} 

Posted by oneofus on 27 September at 10:19 AM

Page 4 of 5 pages for this article « First  <  2 3 4 5 >