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.

How do I create proper path naming structure?

April 28, 2012 11:37am

Subscribe [2]
  • #1 / Apr 28, 2012 11:37am

    stephencapp

    12 posts

    Hello. I’m having an issue with creating path names that make sense. I think it’s just the way I’ve created my template groups but I’m not sure. Perhaps this will be obvious to someone with more experience.

    Below are the three paths that are created when you navigate to the Cheetah Safari page. Cheetah Safari is a trip available under Eastern Africa which is listed under Africa.

    Here’s what I have currently:
    http://localhost:8888/bigplanet_test/continent/africa
    http://localhost:8888/bigplanet_test/continent/country/eastern-africa
    http://localhost:8888/bigplanet_test/continent/trip/cheetah-safari

    What I would rather display is this:
    http://localhost:8888/bigplanet_test/africa
    http://localhost:8888/bigplanet_test/africa/eastern-africa
    http://localhost:8888/bigplanet_test/africa/eastern-africa/cheetah-safari

    I’m using related entries to pull in the countries and trips.

    Here’s some sample code that I have in the index page of the Continent template group:
    {exp:channel:entries channel="continents" limit="1"}

    <h1>{title}</h1>
    {contient_description}

    Countries

      <ul>
      {related_countries}
      <li>{title}</li>
      {/related_countries}
      </ul>

    {/exp:channel:entries}

    Is this an issue that’s handled at the template level or is it category related? Excuse me if this is an obvious noob issue as I’m still trying to wrap my head around EE.

    Thanks!

  • #2 / Apr 28, 2012 3:34pm

    Rob Allen

    3114 posts

    You could use your default template group’s index template to display relevent content.

    {!-- home page --}
    {if segment_1 == ""}
    
      Home page content
    
    {/if}
    
    {!-- test for non home page --}
    {if segment_1 != ""}
    
      {!-- continent level page --}
      {if segment_2 == ""}
    
        {exp:channel:entries channel="continents" limit="1"}
        <h1>{title}</h1>
        {contient_description}
        <h2>Countries</h2>
    <p>    <ul><br />
        {related_countries}<br />
        <li><a href="http://{path={segment_1}/{url_title}}">{title}</a></li><br />
        {/related_countries}<br />
        </ul><br />
        {/exp:channel:entries}<br />
      <br />
      {/if}</p>
    
    <p>  {!-- country level page --}<br />
      {if segment_2 != ""}</p>
    
    <p>    {exp:channel:entries channel="countries" limit="1" url_title="{segment_2}"}<br />
        <h1>{title}</h1><br />
        {country_description}<br />
        {/exp:channel:entries}<br />
      <br />
      {/if}</p>
    
    <p>{/if}

    Something like that would give you a URL structure of http://www.site.com/continent/country - may need a tweak but that’s what I’d look at first.

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

ExpressionEngine News!

#eecms, #events, #releases