ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

looking for suggestions on how to approach this one

September 30, 2010 6:10pm

Subscribe [2]
  • #1 / Sep 30, 2010 6:10pm

    dirksnat

    38 posts

    Hey everyone,

    I’m building a site for a conference that will be held in multiple cities.  Each city will have 5 custom pages unique to that city (landing, about, attendees, exhibitors, sponsors), since the content of the pages will be different at each location.

    I’m envisioning a url structure where the city is a template group with unique templates for each of the pages, so you’d have:

    my-site.com/city-one/
    my-site.com/city-one/about
    my-ste.com/city-one/attendees (etc.)

    and

    my-site.com/city-two/
    my-site.com/city-two/about
    my-site.com/city-two/attendees (etc)

    and on and on.

    My question is, how can I set this up so that the client can add a new city on their own and without creating template groups?

    Hopefully this is easy for you ee gurus out there.  I’m fairly new and still trying to wrap my head around this stuff.  Any suggestions are greatly appreciated!

    Nathan

  • #2 / Sep 30, 2010 6:37pm

    ajlny

    42 posts

    What will the content structure be for each of the sub pages (about, attendees, etc)?

    From the top of my head, there are a couple ways to do this without creating the template groups, but it is really dependent on the content structure of the sub pages.

    Here’s one approach:
    1) Create a channel for each page and one for the main “city”; Users will create an entry in each channel with a unique and shared category “Montreal”
    2) Create a generic template group which keys off the city
    3) Based on the url_segment, display the subpage based off the channel-category combo

  • #3 / Sep 30, 2010 6:51pm

    dirksnat

    38 posts

    That sounds really promising, thanks ajlny!  I tend to shy away from using categories, mostly cause I’m not sure how they work, but this might be the ticket.

    Regarding content structure, each page will have a custom sidebar, a main text area, some repeating images (to show sponsor logos), and one will utilize the simple commerce module to handle exhibitor sign-up and payment, if that’s what you mean by “content structure.”

    I’m pretty clear on steps 1 and 2, its the displaying urls based on channel/category combo that I’m not sure about.  Would it allow for the urls to be organized like they are in the original post?

  • #4 / Sep 30, 2010 7:07pm

    ajlny

    42 posts

    The logic I was thinking of would be something like this (This does assume that the user creates the entries in the proper channels and assigns them the same category):

    1) select the entry based on the “City” blog (would be selected dynamically) based on url, e.g., my-site.com/montreal would pull in montreal entry in City blog
    2) if the url segment is one of the subpages (about, attendees, etc.), then use an embedded template and pass the entry’s category; the embedded template (e.g., .inc.about) would select the entry based on the channel and the specified category id
    3) if the url segment is NOT of the subpages, just display the entry

    my-site.com/montreal/ => display the entry in the City channel
    my-site.com/montreal/about => display the entry in the About channel with the “Montreal” category
    my-site.com/montreal/attendees => display the entry in the Attendees channel with the “Montreal” category
    etc.

  • #5 / Oct 01, 2010 3:07pm

    dirksnat

    38 posts

    I think I understand the approach now, thanks for elaborating.

    I’m gonna try my hand at this and see if I have any luck.  I’ll let you know how it goes!

  • #6 / Oct 01, 2010 4:53pm

    dirksnat

    38 posts

    Ok, so I’ve got it all pretty much set up, but here’s where I’m stuck: 

    How do I “pass the entry’s category” onto the embedded template (#2 above) so that the embedded template pulls only the entry that matches that category?

  • #7 / Oct 01, 2010 6:14pm

    dirksnat

    38 posts

    So I think I’ve got it.  I used exp:query modeled after the one in this blog entry by fortyseven media to pass along the category id to the exp:channel tag in the About template.

    Here’s what I did:

    /* City Selection */
    
    {if segment_1==""}
    
      {exp:channel:categories channel="cities" style="linear"}
         <a href="http://city/{category_url_title}">{category_name}</a> /* Note that the path is supposed to have {path=""} around it.  For some reason everything inside path="" wasn't displaying when I previewed the post so I left it out.*/
      {/exp:channel:categories}
    
    {/if}
    
    /* Individual City Home Page */
    
    {if segment_1!="" AND segment_2==""}
    {exp:channel:entries channel="cities" limit="1"}
    
      {title}
    
      <ul id="nav">
        <li id="home"><a href="/{segment_1}">Home</a></li>  
        <li id="about"><a href="/{segment_1}/about">About</a></li>
        <li id="attendees"><a href="/{segment_1}/attendees">Attendees</a></li> <!-- etc… -->
      </ul>
    
    {/exp:channel:entries }
    {/if}
    
    
    /* Sub-pages */
    
    {if segment_2=="about"}
    
      {embed="embeds/_about"}
    
    {/if}

    And then for the About embedded template:

    {exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_1}'"}
    {exp:channel:entries channel="about" limit="1" dynamic="no" category="{cat_id}"}
    
    {title}
    {about_text}
    
    {/exp:channel:entries}
    {/exp:query}

    This dynamically passes on the category ID to the channel entries tag so that the template will show entries based on the category in segment_1.

    So far so good.  Does anyone see anything wrong with this approach?  Like will my site explode?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases