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

 

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

How I Built One Of Us with Expression Engine

Conditional RSS feeds

You’ll notice a few more sections with

{if}

statements in them. One of these check to see if the section of the site is the news section and if so, it will display some RSS feeds. One of these examples is shown below:

{if seg_1 == "news"}
<h2 style="border:none;">Book news from The Guardian</h2>
<
img src="/images/guardianunlimited.gif" width="120" height="60"  alt="Guardian Unlimited" />
{exp:magpie url="http://www.guardian.co.uk/rssfeed/0,15065,10,00.xml" limit="3" refresh="720"}
{items}
<p><a href="{link}">{title}</a><br/>
{description}</p>
{/items}
{
/exp:magpie}

(The endif statement appears later in the code, after more Magpie code.)

The Magpie feed (using the Magpie RSS Parser plug-in) uses the URL that I took from the Guardian website. The limit parameter tells it how many of the new stories it should show and the refresh parameter is the time in seconds between refreshes (every 12 minutes in this case).

{items}

is the start of the list of stories that the RSS feed pulls in. For each story, it will show the name of the story which is also a link to that story. Beneath it, it will show the brief description of that story.

It’s the use of

{if}

conditionals such as these that made the single template approach possible for the content sections. Here’s what the resulting news feeds look like:

Click on the image to view a larger version.
News feed example

More ifs

I use another

{if}

conditional for the further reading section for the same reasons as the recommended section that I mentioned above.

{if Onthissite != ""}

I use Google Adsense on my website and have setup different channels for each of my site sections. I use another

{if}

conditional to display the correct version of the Google Adsense code in each section.

Don’t forget the year

Finally, I use a handy little parameter called “year” to make sure that my copyright statement is fully up to date:

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

Weblog entry fields

One of the most powerful features of EE for me is the use of weblog entry fields and custom entry fields. I added custom entry fields to allow me to contribute to different sections of each page. I can show the content of these fields anywhere on the page that I like. I can even choose not to show them. The data for each page is all still held together in the database and I can access it all through the weblog entries page.

Meta-data and conditionals

I actually came up with this whilst writing this guide. I was describing how you could use custom weblog entry fields as meta-data and used this as an example. I put the code in (it took 2 minutes to do all of this) just to test that I got the syntax correct and I liked it so much, I kept it.

I added a new custom entry field called maintenance and gave it a dropdown with a value of yes and no. I entered “no” into the list first, so this was the default value.

I then added this just before the “recommended” box-out:

{if maintenance == "Yes"}
<p>I'm sorry, this page is currently down for maintenance and will be back online soon.</p>
{if:else}

and placed the

{/if}

just after the closing weblog:entries tag. Doing this means I can take a page temporarily offline without losing any of the content as it doesn’t get removed from the database. You can see the “maintenance” option in the weblog entry fields list below:

Click on the image to view a larger version.
Weblog entry fields showing the down for maintenance option

Remember that you can make custom weblog entry fields searchable so you can create a field called “contains legal text” and have a yes or no option available as a drop down. You can choose not to display this on the actually web page by simply not putting the

{contains_legal_text}

tag on your page. You can then search for any pages that contain legal text so that you can easily find all examples of legal text. This is very useful for managing a website.

What I plan to do next

I plan to make more use of includes so that I can reuse parts of my content template in other templates, specifically the homepageblog templates. I currently have to update each of them manually with the same change.

I also want to explore the use of global variables so that I can reference a piece of data many times but store it on once place. For example I could place “One Of Us” in a global variable in case I ever wanted to change the name of the site.

Comments?

I said at the beginning that this wasn’t a perfect or ideal example of an EE website, but it’s what’s worked for me. This is my first EE site and you could consider the site itself to be one big tutorial for me as I leant EE as I went along.

Posted by oneofus on 27 September at 10:19 AM

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

Your comments:

Comment 1.

I’m writing for fun. I treat the writing as a hobby. But would still love to discus creative writing with others, maybe professional authors. Who knows, one day I maid be a serious author too.

By Lina Bauer on 2007 10 13

Comment 2.

rdglprec http://uvviwlcr.com baivatjx veyydgsx fqcgsaxu hvpzmihv

By xoyenxms on 2007 11 25

Add your comments:

Name:

Email:

URL:

Remember my personal information

Notify me of follow-up comments?

Please enter the word you see in the image below: