16 - Implementing the Ministries Detail Template

In this chapter of our series, I’ll show how to implement a detail page for each ministry in the church.  The detail page will provide a place to display contact info, show a photo, have paragraphs of text, and allow site visitors to leave comments. From an ExpressionEngine perspective, this chapter is very similar to the weblog comments template, but I will cover a new use of the weblog:entries tag to show related ministries to the one being viewed.

 
Download the EE Code for 16 - Implementing the Ministries Detail Template

Between having already entered content and being able to use weblog/comments as our base, this template should be a fairly quick one to implement.  Here’s an overview of the process it will take to create this page:

  • Create a new template
  • Change the title & location
  • Change the main content
  • Change the sidebar

Create a New Template
The comments template has the basic two-column formatting that will work on this page, and the comments function will serve nicely as a way for the different ministries to allow members to post stories or cool happenings related to the ministry.

So create a new template in the ministries template group, call it “details”, and choose to copy weblog/comments as the basis for the code.

Change the Title and Location
The weblog/comments template has the following code that sets the page title:

{embed="embeds/html_header" 

     
{!--The my_title value will always be used. --}
    my_title
="Weblog | 
    
     {!--This being a single entry page we just need the entry title --}
    {exp:weblog:entries weblog="
weblog" limit="1
    disable="
custom_fields|trackbacks|member_data|pagination|categories"}
        {title}
    {/exp:weblog:entries}
"

For ministries/details change it to:

{embed="embeds/html_header" 

     
{!--The my_title value will always be used. --}
    my_title
="Ministries | 
    
     {!--This being a single entry page we just need the entry title --}
    {exp:weblog:entries weblog="
ministries" limit="1
    disable="
custom_fields|trackbacks|member_data|pagination|categories"}
        {title}
    {/exp:weblog:entries}
"

Then the main navigation active location needs to be changed.  weblog/comments has:

{embed="embeds/main_nav" my_location="weblog"

and this needs to change to:

{embed="embeds/main_nav" my_location="ministries"

Change the Main Content
As usual I’ll attach the complete template to this post, but here is the code for the main content area of the page.  Give it a once-over, then I’ll walk through the significant parts.

<!--BEGIN CONTENT SECTION-->
<
div class="interiorBox">
    <
h2>Ministries</h2>
                    
    <
div class="content_page_right">
         
{!--This is the main weblog:entries tag that will return content for this ministry.   --}
        {exp
:weblog:entries weblog="ministries" 
        
disable="trackbacks|member_data|pagination" limit="1"}
            
<div class="post">
                <
h3>{title}</h3>
                <
img class="ministry_photo" src="{ministry_photo}" alt="{title}" />                            
                
{ministry_main_content}
            
</div>
        
{/exp:weblog:entries}

        {embed
="embeds/comments_form" the_weblog="ministries"}

        
</div>

    <
div class="content_page_left">
        <
div class="ministry_contact">
            <
h3>Ministry Contact:</h3>
            
{exp:weblog:entries weblog="ministries" 
            
disable="trackbacks|member_data|pagination" limit="1"}
                
<p>{ministry_contact_name}<br/>
                
{ministry_contact_email}<br/>
                
{ministry_contact_phone}</p>
            
{/exp:weblog:entries}
        
</div>

        <
div class="navcontainer">
            <
h3>Related Ministries</h3>
            <
ul class="navlist">
                
{exp:weblog:entries weblog="ministries" 
                
disable="trackbacks|pagination" related_categories_mode="on"
                    
<li><a href="{url_title_path=ministries/details}">{title}</a></li>
                
{/exp:weblog:entries}
            
</ul>
        </
div>
    </
div>
    
    <
div class="spacer"></div>
      
</
div><!--END CONTENT SECTION--> 

So overall, a very straightforward EE page here.  The main content is pulled with the standard weblog:entries tag.  Note that the image is pulled in using img tags in the template code vs. the weblog post providing them (a result of choosing the “url only” option while uploading):

<img class="ministry_photo" src="{ministry_photo}" alt="{title}" /> 

The benefit of this is that you can dynamically set the alt text using the weblog entry title.  The downside is that you can’t easily specify an image height and width as your content administrators might upload an image of any size.  Note that you can enforce a maximum height and width in the File Upload Preferences.  Between the two I’d rather have nice alt text.

Next, check out the embed statement that brings in the commenting functionality.  Now is when you start to realize the value of using the embedded approach for comments.  All you need to do to add them to this template is change the weblog name that gets passed in, and voila!—formatted comments and the comments entry form are on your template just like that.

Past that, I have contact information being displayed in the sidebar.  And yes - I am using another weblog:entries tag to content from the same post.  While you can get carried away in that direction and end up with a template with alot of processing overhead, I’m not concerned with the load here.  This coding approach is just easier to read and maintain than trying to use one weblog:entries tag.

Below that tag is another weblog:entries tag with a parameter I’ve not yet covered - the related_categories_mode.  Essentially what I want to do here is show, for any given ministry, what other ministries are in the same category as the one being currently viewed (remember I set up the categories to be demographically-based).  At the moment I only have two entries per category, so only one ministry will show in the related ministries list.  Note that if you assign a given ministry to multiple categories then this tag will return more results - as it will return all categories related to any of the categories the current entry is assigned to.

I have more in mind for this template - I also want to display related events in the sidebar under related ministries.  For that I’ll need to wait until the event calendar is implemented.

What’s Next?
In the next installment I’ll get started on the Worship section of the site.

Category Navigation

<< Previous Entry   

Next Entry >>

 

Previous Comments

Picture of tzTrainEE

by tzTrainEE

Date: Wednesday, July 2nd, 2008
Comment: #1

Thanks again Michael. I was unaware of all the weblog entries tag paramaters. I’ve been struggling with the concepts for weblogs beyond the basics. Planning some categories in my own little dev project, and wondering what all EE could do. All of those are really powerful stuff.

There’s other great tidbits of info in there too.

Happy 4th of July also!

Picture of parsoncraig

by parsoncraig

Date: Wednesday, July 2nd, 2008
Comment: #2

Mike,
I note that it is possible to import data to the membership tables on EE.  Is there a way to create a weblog and then populate it with an import file of any specification on EE? 

Also, I am interested in having this ministries page have three categories of data according to our structure:  ministries, groups, and teams.  The last of these is pretty important, because it refers to cell groups, whereas the former two share more of the attributes of the items in your demo list OR are administrative.  To put it another way, the categories we used to get at the list (kids, teens, single, men, women, seniors) is quite valuable in terms of how someone might want to search, so I want to keep that in place.  But I really need to carve out the cells.

Would you simply replicate the whole structure and create a different weblog and duplicate/edit the templates, or can you imagine way to skin this cat?

Mike Boyink

by Mike Boyink (Author)

Date: Wednesday, July 2nd, 2008
Comment: #3

Search the EE forums for either CSVee or CSVGrab - I can never recall which it is.  Essentially it’s a plug in that allows import to a weblog from a comma separated value file.

For your structure either I’d probably look to use ministries, groups and teams as the categories (and then work in the “for men, for singles” etc as entry titles). 

And I’d probably use “Groups” as the section name rather than Ministries.  I’ve done that on a previous church site.

Note that you can have subcategories as well.

Picture of Efrain Barcena

by Efrain Barcena

Date: Thursday, October 2nd, 2008
Comment: #4

Hey Michael,

I’m glad you haven’t closed comments for this entry! :P

How can I make the “Related Ministries” section display a message when there is no related ministries to display?

Thanks

Mike Boyink

by Mike Boyink (Author)

Date: Friday, October 3rd, 2008
Comment: #5

Hi Efrain: Looking at it again, I’d probably do this:

{exp:weblog:entries weblog="ministries" 
                
disable="trackbacks|pagination" related_categories_mode="on"

{if count
==1}
  
<div class="navcontainer">
   <
h3>Related Ministries</h3>
   <
ul class="navlist">
{/if}

  
<li><a href="{url_title_path=ministries/details}">{title}</a></li>

{if count == total results}
    
</ul>
  </
div>
{/if}

{
/exp:weblog:entries} 

This will go one better than displaying a message if there aren’t any, and will only display the entire block if there is a related ministry.

The other direction you could go is using the
if no results conditional to display your message.

Picture of Efrain Barcena

by Efrain Barcena

Date: Friday, October 10th, 2008
Comment: #6

For some reason the if count == total results does not work for me Mike. Its giving me php erros.

This is working for me:

        {exp:weblog:entries weblog=“ministries” disable=“trackbacks|pagination” related_categories_mode=“on”}
          {if count==1}
              <h3>{if simple_language == “Spanish”}Ministerios relacionados{if:else}Related Ministries{/if}</h3>
              <ul class=“links”>
          {/if}
          <li>{title}</li>
        {/exp:weblog:entries}
        {exp:weblog:entries weblog=“ministries” disable=“trackbacks|pagination” related_categories_mode=“on”}
          {if count==1}
          </ul>
          {/if}
        {/exp:weblog:entries} 

Mike Boyink

by Mike Boyink (Author)

Date: Friday, October 10th, 2008
Comment: #7

That’s probably my fault - it’s “total_results” (underscore between the words).  Sorry about that!

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>