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.

Design: template_group/template or template_group/category

March 28, 2010 10:59pm

Subscribe [2]
  • #1 / Mar 28, 2010 10:59pm

    dsoneil

    11 posts

    Hello,

    I’ve recently taken the plunge into EE from Movable Type and am in the process of migrating / redesigning my site. I’ve noticed that somethings in EE are a bit too easy which is great but I’ve still killed a bunch of time trying to find a harder method 😊

    Anyway, I’ve been looking at options for how to configure my URI’s. I started off with the standard template_group/template but then came across Fortyseven Media’s article on custom category structures. Basically the template_group/index is publishing all of the pages and substituting the category where the template would normally go.

    It works great, and simplifies a lot of things for me, but it seems to make using the search module a tad difficult and the URI’s are not very strict, which could lead to a lot of odd external linking and duplicate content.

    Has anyone else managed to get the search module to cooperate with this URI structure?

  • #2 / Mar 29, 2010 10:33pm

    dsoneil

    11 posts

    A solution that works but…

    Warning: Potentially worst hack ever, I’m not a programmer, but it works.

    Using the FortySeven Media’s example, here’s how I’ve managed to keep the URL structure straight using categories and avoid bogus urls.

    Segment_1 is straight forward:

    {if segment_2=="" AND segment_3==""}

    Displays all of the categories

    Segment_2 is almost the same except I’ve added cat_url_title=”{segment_2} to ensure that categories must exist in the system to be displayed. The page lists all the entries under that selected category.

    <pre><code>{exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_2}’”}
    {exp:channel:entries channel="ingredients" rdf="off" category="{cat_id}” cat_url_title=”{segment_2}”}</code></pre>

    Now for the super hack job:

    Added url_title=”{segment_3}” to ensure that only legitimate posts show up, otherwise a blank page is displayed. I haven’t figured out how to redirect to 404 with this config yet.

    {if:elseif segment_3!=""}
    
    {exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_2}'"}
    
    {exp:channel:entries limit="1" channel="ingredients" rdf="off" cat_url_title="{segment_2}" url_title="{segment_3}"}

    —-Displays the selected article.—-


    Anyway, it works and uses a single index template while also avoiding duplicate content. but I’m not sure of future ramifications or any issues this setup may cause (I don’t see anything really wrong with it). The results look nice:

    http://www.domain.com/template_group/categories/entry

    Hope this helps someone and all suggestions are appreciated.

  • #3 / Mar 31, 2010 11:48pm

    grrramps

    2219 posts

    Anyway, it works and uses a single index template while also avoiding duplicate content. but I’m not sure of future ramifications or any issues this setup may cause (I don’t see anything really wrong with it). The results look nice:

    http://www.domain.com/template_group/categories/entry

    Nicely done.

    This is a major beef I have with EE—URL strings. In reality, the string /domain/index.php/template_group/template/entry doesn’t matter much whether it’s pretty or not (search engines don’t care), but clients do care, and it’s a royal pain to create pretty URL’s in EE.

  • #4 / Apr 01, 2010 8:31am

    dsoneil

    11 posts

    Thanks. I’ve also found a way to have the search module return a valid url. I just use the index template.

    domain.com/template_group/index/entry-title

    I enforce this by only allowing domains with index as the template or a category in segment 2. To allow the index I added the following:

    (if:else segment_2=="index" && segment_3!="")

    To avoid duplicate content I’ve used the canonical link in <head> and direct it to the category based url. Low’s seg2cat extension really helps out.

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

ExpressionEngine News!

#eecms, #events, #releases