17 - Implementing the Worship Section

In this chapter I’ll cover the ExpressionEngine implementation of the Worship section of the example church site.  From a content perspective, the Worship content will live in one place and be displayed on both the Worship page and the site’s home page.  From an EE perspective, the build approach will cover nesting two EE tags to accomplish the content formatting required.

 
Download the EE Code for 17 - Implementing the Worship Section

A Bit of a Direction Change
I’ve decided to implement this section of the site a bit differently than I laid out in the ExpressionEngine Architecture chapter.

It seemed like the basic information around a specific worship event should be able to be communicated right on the index page, without requiring any further navigation.  The page only needs an overview statement about the Worship content, and then just the weekdays and times for the different worship events.  Making that decision simplified the requirements both in the number of custom fields and templates required.

I did allow for a photo or graphic for each Worship event as I have often seen churches do a bit of branding work to help identify the nature of different worship services - be they traditional or contemporary, etc.

I will note - if your needs are such that each worship event should have its own detail page (much like how the Ministries section was implemented) it’s just a matter of at least one more custom field and one more template.  You can follow the Ministries section as a rough guide for how to add that deeper layer of navigation.

Overall Approach
For my approach the overall steps to implementation are:

  • Create a Worship template group
  • Copy page_comps/one-column-content as a starting point
  • Create a Worship weblog
  • Create a Worship field group and Add Fields
  • Create a Worship category group and Add Categories
  • Create a Worship file upload destination
  • Publish content
  • Edit worship/index to pull in content
  • Edit site/index to pull content from Worship weblog

Create a Worship Template Group
I’ve covered the specific steps of creating template groups in past chapters so I’ll gloss over this a bit here.  You just need to come out with a template group named “worship”, and have its index template be a copy of page_comps/one-column-content.

Create a Worship Weblog
Again, at this point in the tutorial, you will have created a few weblogs.  Create another one named “Worship”, and don’t choose to create anything else. 

Create a Worship Field Group & Add Fields
Create a field group named “Worship” and add the following fields.  For each field I’ve listed the Field Name, Field Label, Field Type, Maxlength, Default Formatting, and Searchable settings.

  • worship_image, Worship Image, Text Input, 128, None, No
  • worship_description, Worship Description, Textarea, 12 Rows, Xhtml, Yes

You might notice I don’t have a specific field for the time of the event.  When I looked at how the content would be used it looked like the name of the event and the time would always appear together, so I’m structuring it such that the name and time are always in the title field—so a title would be “Bible Study - 10:30 am”, etc.  You can break that up if you want, you’ll just need another custom field to hold the content and will need to specify it in the code.

Create a Category Group and Add Categories
I plan to use categories to hold the days - so for the example site, Sunday and Wednesday will be categories and I’ll use some category-related EE code to get the different Worship events to appear under the days of the week they occur on.

So create a category group called “Worship”, and then two categories within the group.  One for “Sunday” and one for “Wednesday”.  No category descriptions will be needed.

Connect the Dots
Make sure to connect the new weblog with the new field group and category groups.  You can verify this by clicking “Publish” , choosing the new “Worship” weblog, and ensuring that all the fields and categories appear.

Create a New File Upload Destination
This section will have images or photos associated with it so it’s best to create a new directory on your webserver to hold them (use FTP for that, make sure the folder has read/write/execute permissions) and then create a new File Upload Destination like you did for the Ministries section of the site.

Publish Content
Formatting the template will be easier if you have some content to work with - I went ahead and published an entry for each of the Worship entries indicated by the home page content of the sample site, so 6 entries total with 3 on Sunday and 3 on Wednesday.  Then I added an entry called “Worship Overview” that will provide the content at the top of the Worship page.  This one I did not assign to a category (and that’s crucial, don’t miss it!)

Editing worship/index to Pull Content
I’ll provide a complete template at the bottom as usual, for now I’ll go through the meat of the code that pulls and displays the Worship entries:

<!--BEGIN CONTENT SECTION-->
<
div class="interiorBox">
<
h2>Worship</h2>
{exp:weblog:entries weblog="worship" disable="trackbacks|member_data|pagination" 
url_title="worship-overview" dynamic="off"}
    {worship_description}
    
<br /><br />
{/exp:weblog:entries}

{exp
:weblog:category_archive weblog="worship" style="linear"}
    {categories}
        
<h2>{category_name}</h2>
                                     
        
{exp:weblog:entries weblog="worship" category="{category_id}" sort="desc" 
        
disable="member_data|trackbacks|pagination" dynamic="off"}
            
<img class="worship_image" src="{worship_image}" alt="{title}" />        
            <
h3>{title}</h3>
            
{worship_description}
            
<div style="clear:right;"></div>
        
{/exp:weblog:entries}
        
<br /><br />
    
{/categories}
{
/exp:weblog:category_archive}

</div><!--END CONTENT SECTION--> 

Let’s walk through this.

The first EE tag is pretty straightforward - just a simple weblog:entries set to only pull the Worship Overview entry.  Note that I use url_title to grab the specific entry.  I could also use entry_id - but prefer url_title, for if the post should happen to get deleted and recreated, there is at least a chance the code will hook up and work again. With entry_id it’s guaranteed to not work, as the new entry would have a new ID (they aren’t re—used in EE).

With that out of the way, things get more interesting.  I’ve used a combination of tags - you’ll note that there is a weblog:entries tag nested inside of a category_archive tag. 

Why?

Because I want the page content to be formatted first by category, then with entire entries showing under the category name.  Neither the category_archive tag or the weblog categories tag allow for this type of output.

So instead the category_archive tag is used to loop through the categories, then for a specific category the ID is passed into the weblog:entries tag as a parameter.  Now within the weblog:entries tag I have all the fields available to me, not just the title & url_title.

This might not work if you have many categories and many entries, but for the purposes here it performs just fine—and down the road I can look at caching the page for even better performance.

Oh - also note that the reason the Worship Overview post doesn’t appear in the second chunk of code is that it’s not assigned to a category.

Edit site/index to pull content from Worship weblog
With the main Worship section implemented, now I want to look again at the site home page where it also lists the different Worship times.  When a new worship event is added or the time changes for an existing one, I don’t want to have to update two places in EE. 

In this case, however, I only want the category names and entry titles - so at first glance it seems like a perfect fit for the Category Archive tag.  The obstacle to that approach is the way the HTML is structured with the bolded day name and then the events all in that day being wrapped in paragraph tags.  Without the paragraph tags the line-heights aren’t right and the content looks goofy. Getting the paragraph tags in using the Category Archive is tough because you’d need to open it within the category pair and close it within the entries pair, and the tag lacks the count and total results variables that would allow the closing paragraph tag to only be generated after the last item in the entry pair.

So - the choices were to re-work the css or choose a different EE approach.

I chose to use the same basic idea as I used on the Worship page - and nest a weblog:entries loop inside a category_archive loop:

<div class="join_us_column">
    
{exp:weblog:category_archive weblog="worship" style="linear"}
        {categories}
            
<p><b>{category_name}</b><br />
                                     
            
{exp:weblog:entries weblog="worship" category="{category_id}" sort="desc" 
            
disable="member_data|trackbacks|pagination" dynamic="off"}
                {title}
<br />
                
{if count==total_results}
                    
</p>
                
{/if}
            {
/exp:weblog:entries}
        {
/categories}
{
/exp:weblog:category_archive}
</div

This gives me access to the count and total results variables so I can determine when to close the paragraph tag.

So There You Have It
A Worship section, with an overview paragraph and entries per worship event with each event having a text description and image.  Content is maintained in one place and displayed in two.  I’ll come back to this page once the podcasts are in place, and will show how to display the 2 or 3 most recent podcasts from the relevant events.

Next up is the Beliefs section, which should be pretty straightforward.

Category Navigation

<< Previous Entry   

Next Entry >>

 

Previous Comments

Picture of parsoncraig

by parsoncraig

Date: Friday, July 11th, 2008
Comment: #1

Mike,
Is it your perception that the data in this weblog is relatively static?  That is, a one-time setup that works until those recurring events change?  Or do you envision a church staff creating entries that are timely for the specific weeks ahead, such that holy day observations and feasts (of the saints) for which the Eucharist is celebrated are input here (and, I presume, also in the Events Calendar).  I am trying to imagine this latter case.  You could set up an entry that does not expire for the standard services, and set up expiring entries for those like Maundy Thursday or Christmas (which falls each year on a different day/category).  The next year you could search for that expired entry, I presume, and edit it to get the right day/category.  Is that what you are imagining?

And are you assuming here an acceptable redundancy between the events calendar and worship events, or do you see a clear line that determines what qualifies something for either weblog.

Mike Boyink

by Mike Boyink (Author)

Date: Friday, July 11th, 2008
Comment: #2

You’re asking about an issue that really becomes semantic - what defines an event vs. a worship service.

Since I’m dealing in the fictional here it’s not that hard - services are services and events are events..;)

I see Worship - current entries aside - as being the repeating, open to all members, type thing.

Events are special, one-off, targeted to subsegments of the church.

In reality there may be some cross-over, and your examples of Christmas etc might be posted here in the way you describe.

Picture of parsoncraig

by parsoncraig

Date: Sunday, July 13th, 2008
Comment: #3

Couple of things I noted, Mike, that you may have handled in a different way, and also a suggestion to add utility to this section for real churches.

1. Since we don’t just have Sunday and Wednesday services but routinely celebrate the Eucharist (the Lord’s Supper) throughout the week in accordance with appointed feast days (such as the upcoming celebration of the Transfiguration), we need to have more than just two categories for Monday and Wednesday.  We need all seven days.  Accordingly, I had to add a “show_empty” = no parameter.

2. To get the clean look that your placeholders provide, I had to had a width parameter of 250px to the img.  I tried to use imagesizer but got an error.  The basis width=250 parameter worked.

3.  I found it helpful to add two things.  First, a line just below the first non-categorized worship description that appears at the top of the page.  I added a custom field called “duty_roster_url” and a link to that field where you can “Click here to download the current worship team duty roster.”  Others might prefer to do that on a branded worship service basis so that it appears in each element, but we only do one roster that shows all for the month.  The goal is to have one “refrigerator-ready” downloadable PDF that serves as a reminder to parishioners of their commitments.

2.  I added a field called “music_notes”.  We find it important to teach about the music we will be featuring and put this in the bulletin. Our plan is to add those notes here.

Picture of Daniel Barrett

by Daniel Barrett

Date: Monday, March 9th, 2009
Comment: #4

I was also wondering about the no parameter on category days where there were no events (I put in all seven days, too, because there are many things happening). So where does the “show_empty” = no parameter go exactly?

Picture of Daniel Barrett

by Daniel Barrett

Date: Monday, March 9th, 2009
Comment: #5

By “events”, I’m referring to this section of “worship events”.

Mike Boyink

by Mike Boyink (Author)

Date: Monday, March 9th, 2009
Comment: #6

Show_empty=“no” is a parameter available the category archive tag, so would go in the opening tag of that pair.

Picture of Diane

by Diane

Date: Wednesday, March 11th, 2009
Comment: #7

Mike, at this point should I be able to open up my sitename/index.php and link to the weblog and ministries pages?  Seems like I should be able to, but I cannot.  I was not sure if there was something coming down the road?

Mike Boyink

by Mike Boyink (Author)

Date: Wednesday, March 11th, 2009
Comment: #8

Diane - you shouldn’t have to open index.php for anything. 

Edit embeds/main_nav to link to the new pages.

Picture of Diane

by Diane

Date: Wednesday, March 11th, 2009
Comment: #9

I changed the href= to href={path=.. in the main_nav and it works fine!  thanks!

Picture of Gary

by Gary

Date: Friday, December 3rd, 2010
Comment: #10

Hi,

You mentioned that the category_archive might not work if there are many categories and entries. Why is that so? Is there any workaround if there are many categories and entries? After all an archive tag should be able to maintain an archive however large it may be.

Mike Boyink

by Mike Boyink (Author)

Date: Friday, December 3rd, 2010
Comment: #11

Simple volume & size of queries that need to run regardless of how the category tag is implemented it won’t scale indefinitely with satisfactory page load times.

Add Your Comment

Commenting is not available in this channel entry.

Unless otherwise stated all content is © Michael Boyink of Train-ee.com & Boyink Interactive. Please don't steal - I've got kids to feed...

dy>