29 - Getting the Audio Messages on the Website
I’ve been talking about Podcasts all along, but there are actually three ways I want to let people consume the mythical recordings of our pretend church pastors - with a “play” button right on the the website, a link to download the .MP3 file, and a true Podcast that wraps the .MP3 files in an RSS feed. In this chapter I’ll cover the first one.
I’m lazy - whenever I need to implement a new website section, I look for shortcuts. Have I already done some work I can leverage for the new section? Copying existing templates is way faster than starting over again. In this case, I looked through the site as it sits, and it occurred to me that the weblog section was a great starting point. It’s setup with categories, archives, and comments—all great stuff for the audio/podcast section. Categories in this case will contain message series, and archives will be handy as people often will want to find messages by date.
So - that sets the build approach for this section:
- Create a new template group by duplicating the weblog templates
- Update weblogs & paths etc in new templates
- Reformat content area
- Repurpose existing embedded templates
- Update other templates using those embeds
Create a New Template Group
I named my template group “audio-messages” and copied the weblog’s templates while doing so. The new template group will sort by default to the bottom of the Template Groups. To change this, Choose Edit Group Order, then Alphabetize to get it sorted to the top where it should be.
Update Template Code
The next step is to run through both audio-messages/index and audio-messages/comments and change:
- All weblog references to “audio-messages”
- The html body id to “audio” (so the banner image changes out)
- The my_location variable to an empty string to prevent the main navigation active state from showing
- The path variables to point at audio-messages/index rather than weblog/index
Reformat Content Area
I do have different fields in the audio-messages section than in the weblog. I also want to fit in a Wimpy Player Button. Below is the code that I’m using in the post div on both audio-messages/index and audio-messages/comments (I’ll also include an updated stylesheet in the companion files).
<div class="post">
<h3>{entry_date format='%F %d, %Y'}</h3>
<em>{message_summary}</em>
<div class="wimpy_player_right">
<p>Wimpy Player <br />Placeholder</p>
</div>
<div class="sermon_details_left">
<p>Title: <strong>{title}</strong></p>
<p>Series: <strong>{categories}{category_name}{/categories}</strong></p>
{if worship_service !="0"}
<p>Service: <strong>{related_entries id="worship_service"}{title}{/related_entries}</strong></p>
{/if}
{if number_in_series}
<p># in Series: <strong>{number_in_series}</strong></p>
{/if}
{if scripture_verses}
<p>Verses: <strong>{scripture_verses}</strong></p>
{/if}
<p>Download Audio: <strong><a href="{site_url}audio_files/{audio_file}">{audio_file}</a></strong></p>
</div>
<div style="clear: both;"></div>
<div class="post_meta">
<p>By {url_or_email_as_author}
{if allow_comments}({comment_total}) <a href="{url_title_path=audio-messages/comments}#comments">Comments</a>{/if}</p>
</div>
</div>
The only real thing of note here is the use of conditionals to only show field titles if there is content in them. Note that:
{if scripture_verses}
is the same as saying:
{if scripture_verses != ""}
This is taking advantage of the shorthand syntax for conditionals.
Also checking for an empty relationship field is slightly different:
{if worship_service !="0"}
For the link to the audio file, I’m assuming the file has been updated via FTP, and just the file name posted into EE. Then the template is creating the link back to the file:
<a href="{site_url}audio_files/{audio_file}">
Repurpose Embedded Templates
If you recall, the left navigation in the weblog is handled by two embedded templates - embeds/weblog_category_nav and embeds/weblog_archive_nav. Functionally these two templates do exactly what I want them to in this section, they just don’t pull from the right weblog or link to the right spot. Since I’ve matched the weblog name and template group name, I can make these two existing embedded templates work for both the weblog and audio section by passing in that value as an embedded variable. I’ll include both the updated templates in the companion files, so will cover the changes to just one of them here.
Here is the template as we finished it for the weblog:
<div class="navcontainer">
<h3>Archives</h3>
<ul class="navlist">
{!--This tag will build the left-column archive subnavigation --}
{exp:weblog:month_links weblog="weblog" limit="50"}
<li>
<a
{!--This conditional will cause the link to the currently-viewed archive choice to be highlighted --}
{if segment_2==year AND segment_3==month_num}
class="active"
{/if}
href="{path=weblog/index}"> {month}, {year}
</a>
</li>
{/exp:weblog:month_links}
{!--This conditional will create a show all posts link only if an archive link was selected --}
{if segment_2 !="category" AND segment_3!=""}
<li><a href="/index.php/weblog/">Show All Posts</a></li>
{/if}
</ul>
</div>
And here’s what it needs to be:
<div class="navcontainer">
<h3>Archives</h3>
<ul class="navlist">
{!--This tag will build the left-column archive subnavigation --}
{exp:weblog:month_links weblog="{embed:my-section}" limit="50"}
<li>
<a
{!--This conditional will cause the link to the currently-viewed archive choice to be highlighted --}
{if segment_2==year AND segment_3==month_num}
class="active"
{/if}
href="{path={embed:my-section}/index}"> {month}, {year}
</a>
</li>
{/exp:weblog:month_links}
{!--This conditional will create a show all posts link only if an archive link was selected --}
{if segment_2 !="category" AND segment_3!=""}
<li><a href="{path='{embed:my-section}/index'}">Show All Posts</a></li>
{/if}
</ul>
</div>
You can see all weblog and path references now use the passed-in variable of my-section rather than being hardcoded. The only real clever thing going on here is the matching of weblog names and template group names - it allows me to pass in only one value that works for both purposes. However now that I’ve made these templates more reusable I don’t like their names as they sound weblog-specific. I’m going to rename them to:
- embeds/sidebar_archive_nav
- embeds/sidebar_category_nav
You can rename templates by clicking on the Preferences link in the center column when a template group is active. Once in the Preferences area, enter the new name for the template and click update.
Updating the Embed Statements
With the embeds updated and renamed I now have to update the embed statements that call them. I’ll start with weblog/index and weblog/comments. These were previously:
{embed="embeds/weblog_category_nav"}
{embed="embeds/weblog_archive_nav"}
And they need to be:
{embed="embeds/sidebar_category_nav" my-section="weblog"}
{embed="embeds/sidebar_archive_nav" my-section="weblog"}
In audio-messages/index and audio-messages/comments this code needs to be:
{embed="embeds/sidebar_category_nav" my-section="audio-messages"}
{embed="embeds/sidebar_archive_nav" my-section="audio-messages"}
With these templates updated I now have a working web-presentation of audio-messages with category and archive views and the ability to comment on a message.
Update Utility Navigation
With the new section now implemented I need to provide navigation to it. Update embeds/page header to link to the new section:
<a href="{path='audio-messages'}">Audio Messages</a>
Template Checklist
I’ve done a fair amount of template work in this chapter. Let me recap:
New Template Group:
- audio-messages
New Templates:
- audio-messages/index
- audio-messages/comments
Renamed/Updated Templates:
- embeds/weblog_category_nav to embeds/sidebar_category_nav
- embeds/weblog_archive_nav to embeds/sidebar_category_nav
Updated Templates:
- weblog/index
- weblog/comments
- stylesheets/style
- embeds/page_header
For my next trick, I’ll get the Wimpy player button installed and working so that site visitors can click a simple play button to hear the message right on the website.
Category Navigation







by Kevin
Date: Monday, November 24th, 2008
Comment: #1
Mike,
Thanks for the next series installment! Regarding the Wimpy Player, is it part of your plan to create a playlist from EE to play in the Wimpy Player (such as latest 10 sermons, or playlist based on the sermon series selected)? Just wondering if your intention would be to touch on playlists / feeds?
Where I see EE being so powerful as a church CMS is in podcasting / media presentation. You could dynamically create an RSS feed for any of the following: all sermons, a certain series, by or even by speaker (Weird, I know, but maybe if you like to follow a particular speaker).
Regarding media presentation: On a sermon series page you could have an xml feed dynamically created by EE for an online Flash player such as Wimpy / JW Player of the sermons (sorted by date) right on the website! No PODCASTING required!
Mike, thanks for so thoughtfully working through this series. I pray that many a church/designer will buy this series as an e-book when the series is complete, and aim to reach the world even more effectively with the Good News!
Kevin