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.

single entry display: require_entry="yes" returning no results with seemingly valid URL

August 03, 2012 12:02pm

Subscribe [2]
  • #1 / Aug 03, 2012 12:02pm

    LukeM

    7 posts

    This question may be related to a resolved thread.

    Hi,

    I need help displaying a single entry! 

    To display a single entry, I make use of the comment_url_title_auto_path feature as suggested in the above thread and other threads. This approach is successful for one channel (people) but not another channel (horses).  Both channels have several entries.

    Here are some relevant Channel Preferences for the two channels People and Horses:

          People
              Channel URL =  http://mysite/community
              Comment Page URL = http://mysite/community

          Horses
              Channel URL = http://mysite/community/horses
              Comment Page URL = http://mysite/community/horses

    The index page http://mysite/community uses conditional statements that depend on the segment variables to embed various templates.  On that index page there are two types of links:

    {exp:channel:entries channel="people"}
     <a href="http://{comment_url_title_auto_path}" title="Member Profile">{title}</a>
    {/exp:channel:entries}
     
    {exp:channel:entries channel="horses"}
     <a href="http://{comment_url_title_auto_path}" title="Horse Profile">{title}</a>
    {/exp:channel:entries}

    The first points to something like http://mysite/community/example-person.  The second points to something like http://mysite/community/horses/example-horse.

    Results for http://mysite/community/example-person:

          Here, segment_2 does not equal “horses”, so the site embeds a template that uses this tag

    {exp:channel:entries channel="people" limit="1" require_entry="yes"}
     Member Profile content
    {/exp:channel:entries}

    As expected, the member profile content is displayed. 

    Results for http://mysite/community/horses/example-horse:

    Here, segment_2 equals “horses”, so the site embeds a template that uses this tag

    {exp:channel:entries channel="horses" limit="1" require_entry="yes"}
     Horse Profile content
     {if no_results}
      Sorry, we got nuthin on this horse…
     {/if}
    {/exp:channel:entries}

    Unexpectedly, the no_results content is displayed.  Removing the require_entry and limit parameters will display all entries for the channel horses. 

    Any help is appreciated! 

    Thanks,

    Luke

  • #2 / Aug 03, 2012 1:56pm

    LukeM

    7 posts

    OK, so here is an update. The problem seems to have something to do with how many segments are in the Channel URL and Comment Page URL in the Channel Preferences.  In the post above, the single entry Horse Channel is broken and does not display.  Call that Case A.

    If I set the preferences like so (Case B):

        People
          Channel URL =  http://mysite/community
          Comment Page URL = http://mysite/community

        Horses
          Channel URL = http://mysite/horses
          Comment Page URL = http://mysite/horses

    Then both channels work.  http://mysite/horses/example-horse will display a single entry.  http://mysite/community/example-person will display a single entry. 

    Strangely, if I set the Channel Preferences like so (Case C):

        People
          Channel URL =  http://mysite/community/people
          Comment Page URL = http://mysite/community/people

        Horses
          Channel URL = http://mysite/community/horses
          Comment Page URL = http://mysite/community/horses

    Then both channels are broken.  Neither http://mysite/community/horses/example-horse nor http://mysite/community/people/example-person will display a single entry.

    I prefer the URL structure of Case A. Case C is also ok.  But Case B, which is the only case where both channels can display single entries, is least desirable. 

    Any ideas why it should matter how many segments appear in the Channel URL and the Comment Page URL?

  • #3 / Aug 06, 2012 11:54am

    Shane Eckert

    7174 posts

    Hey Luke,

    Thank you for posting your question here on the ExpressionEngine forums.

    The Channel URL is going to be the URL of the channel, which in your case is http://mysite/horses and http://mysite/community. Anything added to that will not work because it’s not the root of the url, you are adding segments that do not exist.

    Does that makes sense?

    Unless you use dynamic=no, everything ExpressionEngine does is based on what is in the URL.

    I hope that helps.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases