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.

Dynamic URL structure with single template file

February 09, 2012 7:11am

Subscribe [3]
  • #1 / Feb 09, 2012 7:11am

    dabcat

    7 posts

    I’m trying to figure out how to create best SEO wise URL structure for a project I’m working on.

    Currently the URL structure is like this:

    I have “challenge” template group, and journal.html template (among others). URL to the specific entry in channel “challenges” looks like this:

    domain .com/challenge/journal/[entry_id]

    When user creates a challenge it can pick from the dropdown challenge goal e.g.:

    - get a six pack
    - loose fat
    - build muscles

    The URL structure I would like to have would be domain .com/challenge/[challenge_goal]/[entry_id]

    Is that possible?

    Desirable URL would be something like:

    domain .com/challenge/loose-fat/38
    domain .com/challenge/build-muscles/66
    domain .com/challenge/get-a-six-pack/12

  • #2 / Feb 09, 2012 7:40am

    the3mus1can

    426 posts

    You can use segment conditionals in the index.html template in the challenge template group. Below is an simple example:

    {if segment_2 != 'journal'}
      {embed="_embeds/.goal-entry" goal_url_title="{segment_2}" entry_id="{segment_3}"}
    {if:else}
       --- other stuff ---
    {/if}

     

  • #3 / Feb 09, 2012 9:21am

    dabcat

    7 posts

    Thanks for quick reply. I’m basically a newbie with EE so if you could explain a bit more please? 😊

    I dont quite understand embed part of the code.

  • #4 / Feb 09, 2012 9:39am

    the3mus1can

    426 posts

    Take a look at http://ellislab.com/expressionengine/user-guide/templates/embedding.html and see if it helps.  Post back if you have more questions.

  • #5 / Feb 11, 2012 3:40am

    lincolnpixel

    83 posts

  • #6 / Feb 11, 2012 4:44am

    Bhashkar Yadav

    727 posts

    it will be good practice to use URL TITLE instead of entry id

    domain .com/challenge/journal/[url_title]

    it will be more SEO friendly.

  • #7 / Feb 13, 2012 3:45am

    dabcat

    7 posts

    Thanks for help everyone! I’ll try to make something.

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases