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.
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. If you want a sneak peek at the finished template you can get one here:
http://church.train-ee.com/index.php/ministries/details/crafty-old-people/
Here’s an overview of the process it will take to create that 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







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!