Boyinks4Adventure - Pretrip Blog

I’ve already posted the Archives Template for the Pre-trip Blog - here are the rest of the EE templates that round out the Pre-trip blog on Boyinks4Adventure.com.

 
Download the EE Code for Boyinks4Adventure - Pretrip Blog

My main goal for this section was to keep the URLs clean - with no /comments/ segment in the single-entry view.  As with anything in ExpressionEngine there are a couple of ways to go about the development.

I chose to use the pre-trip/index template as a controller template.  All it does is read the URL and embed in the full-page template required to display content indicated in the URL:

{exp:md_detect_page_type url_segment="{segment_2}"}

    {
!-- Loads the default index view --}
    {if segment_2 
== ""}
        {
!-- Load the weblog multi-entry/index view --}
        {embed
="pre-trip/multi-entry"}
    {
/if}

    {
!-- if something else in the URL use Masugas plugin to decide what to present --}
    {if segment_2 
!= ""}
        {if pagination_page 
OR yearly_archive_page}
            {embed
="pre-trip/multi-entry"}
        {if
:elseif category_page}
            {embed
="pre-trip/multi-entry"}
        {if
:else}
            {
!-- If not categoryarchive or pagination page it must be a single entry--}
            {embed
="pre-trip/single-entry}
        {/if}
    {/if}

{/exp:md_detect_page_type} 

The trick in this template is to use the MD Detect Page Type plugin from Ryan Masuga.  It eases the pain of accommodating the different URL structures that you’ll encounter working with blogs - including category urls and paginated urls.

Note that there is no logic here to accomodate the archives template (which is stored in the same Pre-trip template group).  When EE encounters the http://boyinks4adventure.com/pre-trip/archives/ URL it looks first for a template named /archives/ before falling back to the index template.  Since /archives/ exists it gets loaded and this index template isn’t entered.  This is good to know for when you have unique templates within a template group that need to function alongside an index template with more logic in it like this one.

From there the multi-entry and single-entry templates are relatively straightforward with a couple of notes:

  • Boyinks4Adventure.com and Boyink.com are both running off a Multiple Site Manager installation, and the Pre-trip content actually lives in the Boyink.com site (as we started posting before I had the adventure site built).
  • I have a new “Our Travels” section to put live once we actually start moving on our trip - so some of the sidebar elements are coded to be reusable by passing site and blog names as Embed Variables for Embedded Templates

So - grab the code, pull it apart, destroy, rebuild, improve!

Category Navigation

<< Previous Entry   

 

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>