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.

implementing super-clean urls for a blog

December 04, 2009 2:26pm

Subscribe [1]
  • #1 / Dec 04, 2009 2:26pm

    arilyn

    8 posts

    I am in the process of developing a blog with EE2, and I was wondering how best to get this type of URL for single entries: http://site-name.com/category-name/this-is-a-post

    I’ve been doing a lot of searching/reading on this topic and have been able to remove index.php and template_group. However, removing the template name (“entry” in my case) and injecting category names into the URL has been eluding me. This is what I have so far:

    Single Entry (original)
    http://site-name.com/index.php/site/entry/this-is-a-post

    Single Entry (current)
    http://site-name.com/entry/this-is-a-post

    Single Entry (ideal)
    http://site-name.com/category-name/this-is-a-post

    So I guess I have two separate problems: (1) I would like to remove the template name for single entries and (2) add the category of the entry into its URL. Thanks in advance for any help.

    Edit: These links have to be able to work both from http://site-name.com and http://site-name.com/category-name.

  • #2 / Dec 04, 2009 2:43pm

    ender

    1644 posts

    the no-programming way to do this is to use the pages module to specify the exact URI you want for each post.  That solves both problems because you can access the page_uri from the weblog:entries tag (http://expressionengine.com/docs/modules/weblog/variables.html#var_page_uri).

    edit: someone will probably stop in here and tell you to build with structure.  I’ve never used it, apparently it’s amazing… <shrug>

  • #3 / Dec 04, 2009 3:08pm

    grrramps

    2219 posts

    the no-programming way to do this is to use the pages module to specify the exact URI you want for each post.  That solves both problems because you can access the page_uri from the weblog:entries tag

    I remember reading that Pages URL’s are stored in an array, so there might be a performance hit if the site has many, many pages of content, each with a different Pages URL (large array).

    edit: someone will probably stop in here and tell you to build with structure.  I’ve never used it, apparently it’s amazing… <shrug>

    Where/What is ‘structure?’ IMW2K.

    I don’t have a major issue with EE’s URL string. index.php can be removed easily enough, and the Template Group/Template/name-of-entry can provide modest help in URL/keyword/content density. That said, clients have become very directive about how they want the URL string to look. Pages works for sites with fewer pages and lower traffic (not sure beyond that).

  • #4 / Dec 04, 2009 5:43pm

    ender

    1644 posts

  • #5 / Dec 04, 2009 7:18pm

    grrramps

    2219 posts

    http://buildwithstructure.com/

    Ender, thanks.

    Lord, that’s interesting.

    Lord, that’s pretty slick.

    Lord, yet another hack to track.

    Sigh.

    😉

  • #6 / Dec 06, 2009 5:12pm

    arilyn

    8 posts

    Well, I figured it out without Structure. I split my site into four channels and made a template group for each channel. For the index template of each template group, I use segment conditionals to remove the need for single entry templates.

    {if segment_2 == ""}
    <!-- code to view a list of entries -->
    {/if}
    
    {if segment_2}
    <!-- code for viewing a single entry -->
    {/if}

    And then in Channel Preferences, I set Comment Page URL to http://site-name.com/template-group, which results in the pretty URLs that I was trying to achieve: http://site-name.com/section/this-is-an-entry

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

ExpressionEngine News!

#eecms, #events, #releases