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.

Problem with dynamic weblogs / "index" required in URL

August 02, 2009 11:37pm

Subscribe [3]
  • #1 / Aug 02, 2009 11:37pm

    philfreo

    50 posts

    I’ve taken over development of an EE site and have run across a problem that I’ve never had before, and am not sure of the cause.

    If I access an URL via both the template group (“articles”) and template name (“index”), it works:
    http://example.com/articles/index/
    I see the template, and my {exp:weblog:entries weblog="content_articles"} tag outputs all of my entries.

    However if I access a URL without “index”:
    http://example.com/articles/
    Then I see the correct template (articles/index) however the weblog tag does not output any entries.

    I want to be able to access
    http://example.com/articles/
    http://example.com/articles/an_entries_url_title/

    I can fix the problem with dynamic=“off” and url_title=”{segment_2}”, but it didn’t seem like this was the correct way to do it.  Shouldn’t dynamic=“on” do this automatically?  Is it correct to use dynamic=“off” in this situation?  What else could be causing this?

  • #2 / Aug 03, 2009 2:11am

    John Henry Donovan

    12339 posts

    philfreo,

    What version and build of EE are you using?
    Are you using a htaccess to remove the index.php?

  • #3 / Aug 03, 2009 2:23am

    philfreo

    50 posts

    version 1.6.8, build 20090723

    Yes, I’m using the “include” method in .htaccess to remove index.php

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5})$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} ^/(about|articles|resources|contact|main|_includes|P[0-9]{2,8}) [NC]
    RewriteRule (.*)$ /index.php?$1 [L]
  • #4 / Aug 03, 2009 2:40am

    John Henry Donovan

    12339 posts

    philfreo,

    What have you got Enable Strict URLs set to?

    Templates > Global Template Preferences

    This setting determines whether or not ExpressionEngine allows Templates from your default Template Group to be directly accessed in the first URL segment.

    EE Docs : Global Template Preferences

  • #5 / Aug 03, 2009 2:43am

    philfreo

    50 posts

    I forgot to mention that… I’ve tried with Strict URLs both enabled and disabled - with no change.  (I’m guessing there is no effect because “articles” is not my default template group).

  • #6 / Aug 03, 2009 3:22am

    John Henry Donovan

    12339 posts

    philfreo,

    Then using dynamic=“off” would be suitable in this case where you want to output the entries from content_articles but don’t want them affected by the URL

  • #7 / Aug 03, 2009 9:40am

    philfreo

    50 posts

    Does that really make sense though?  I *do* want the the weblog to dynamically choose its entries based on the URL.  It seems like what I’m doing isn’t an exception for how dynamic=“on” should work… it seems like it’s the norm.

    I consider this either
    -a bug (and that dynamic=“on” should do the same thing whether accessed either with “/” or “/index” trailing the template group name)
    -something incorrect in my configuration (if so, where else would I look for this? Can you confirm that this works the same way in another setup?)

  • #8 / Aug 03, 2009 9:56am

    Sue Crocker

    26054 posts

    Let’s try something..

    Try removing your .htaccess file, and visit http://example.com/index.php/articles/ - what happens then?

  • #9 / Aug 03, 2009 11:51am

    philfreo

    50 posts

    Same thing.
    The weblog tag with dynamic=“on” shows nothing at http://example.com/index.php/articles/ whereas http://example.com/index.php/articles/index/ shows all the entires.

  • #10 / Aug 03, 2009 5:30pm

    philfreo

    50 posts

    Any other ideas?  It’d be good for someone to at least confirm whether or not the two URLs above *should* be returning the same results with a {exp:weblog:entries dynamic="on" weblog="content_articles"}.  Like I said, I feel like they should be, but what is the documented or reproduced behavior?

  • #11 / Aug 03, 2009 5:44pm

    Lisa Wess

    20502 posts

    dynamic= shouldn’t be coming into play in this case.  Can you post your template please?

  • #12 / Aug 03, 2009 5:57pm

    philfreo

    50 posts

    Sure.  Normally people have problems getting the correct template to show up, but this is not my problem.  My “articles/index” template is showing up at both URLs - but the weblog tag is only producing the correct content if a) dynamic=“off” or b) I include “/index” after the template group.

    Template that works at http://example.com/articles/index/ (outputs entries)
    If I access it via http://example.com/articles/ the same template is shown but no entries are outputted.

    {embed="/_includes/_top" url_title="{url_title}" page_name="Articles"}
    My articles template
    {exp:weblog:entries weblog="content_articles" dynamic="on" cache="no" refresh="60" show_future_entries="no" show_expired="no" disable="member_data|trackbacks|comments|pagination|categories|category_fields"}    
        <h1><a href="/articles/{url_title}/">{title}</a></h1>
    
        {content_extended}
    
    {/exp:weblog:entries}
    {embed="/_includes/_bottom"}

    —-

    Template that works at /articles/ but requires me to use dynamic=“off”

    {embed="/_includes/_top" url_title="{url_title}" page_name="Articles"}
    My articles template
    {exp:weblog:entries weblog="content_articles" dynamic="off" cache="no" refresh="60" show_future_entries="no" show_expired="no" disable="member_data|trackbacks|comments|pagination|categories|category_fields"}    
        <h1><a href="/articles/{url_title}/">{title}</a></h1>
    
        {content_extended}
    
    {/exp:weblog:entries}
    {embed="/_includes/_bottom"}


    Like I said before, I can use a workaround of dynamic=“off” and url_title=”{segment_2}” but it seems to me like dynamic=“on” should work here instead.

  • #13 / Aug 03, 2009 6:05pm

    Lisa Wess

    20502 posts

    Can you do this with a totally minimal template:

    {exp:weblog:entries limit="10" weblog="content_articles"}
    {title}
    
    {/exp:weblog:entries}

    and give us a link to the template please?

  • #14 / Aug 03, 2009 6:08pm

    philfreo

    50 posts

    Can you do this with a totally minimal template:

    {exp:weblog:entries limit="10" weblog="content_articles"}
    {title}
    
    {/exp:weblog:entries}

    and give us a link to the template please?

    Sure.  I’ve edited my articles/index template to be the above.  Here’s a link:
    [removed]


    You’ll notice the page is blank, but if you append “index” then it works.

  • #15 / Aug 03, 2009 6:26pm

    Lisa Wess

    20502 posts

    Can you turn on template debugging and post the full results of the template debugging?

    Also, are you running any extensions?

    Can you add one other thing to that? Just above the weblog entries tag, just put:

    <h1>HELLO WORLD</h1>

    Thanks!

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

ExpressionEngine News!

#eecms, #events, #releases