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.

entry_id AND url_title segments BOTH affecting dynamic Channel Entries tag?

May 22, 2011 1:47am

Subscribe [3]
  • #1 / May 22, 2011 1:47am

    Brett Gullan

    70 posts

    Hi,

    I’ve run across some strange behaviour with channel entries and url segments.

    I have the following url pattern:

    <a href="http://somedomain.com/index.php/clients/lightbox-photo/19/7669">http://somedomain.com/index.php/clients/lightbox-photo/19/7669</a>

    In this case, {segment_3} refers to the entry_id I want the Channel Entries tag in the template to display as a single entry page. {segment_4} (which has value of 7669) has nothing to do with the Channel Entry—it’s actually the value of a Matrix field, which I need to use within the (lightbox-photo) template.

    My problem is that the Channel Entries tag is evaluating BOTH segments. Segment 3 is being interpreted (correctly) as the entry id. Segment 4 is being evaluated (incorrectly, I think?) as the url_title. BOTH are being evaluated by the Channel Entries tag—thus I get no results!

    Here’s the SQL that’s being generated:

    SELECT t.entry_id FROM exp_channel_titles AS t
    LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id 
    LEFT JOIN exp_members AS m ON m.member_id = t.author_id 
    WHERE t.entry_id !='' AND t.site_id IN ('1')  AND t.entry_date < 1306038209  
    AND (t.expiration_date = 0 OR t.expiration_date > 1306038209) AND t.entry_id = '19' 
    AND t.channel_id = '11' AND t.url_title = '7669' AND t.status = 'open' 
    ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc LIMIT 0, 1

    I’ve not encountered this before. I’m pretty sure EE isn’t supposed to work that way?

    Any pointers would be appreciated.

    Thanks,

    Brett

  • #2 / May 22, 2011 8:17am

    Mark Bowen

    12637 posts

    Can you show us your Channel Entries Tag code which you are using in your template.

    If you have dynamic=“no” set in the tag and then specify each part that you want to use in the tag then you should be okay I think.

    {exp:channel:entries
        channel="default_site"
        entry_id="{segment_3}"
        limit="1"
        dynamic="no"
        sort="asc"
        disable="member_data|pagination|categories"}
    
    {title}
    
    
    {/exp:channel:entries}

    Best wishes,

    Mark

  • #3 / May 22, 2011 10:22am

    Brett Gullan

    70 posts

    Hi Mark,

    Here’s my Channel Entries tag:

    {exp:channel:entries 
        channel="lightbox" 
        author_id="{logged_in_member_id}"
        limit="1"
        }

    ... and you’re right, if I use this:

    {exp:channel:entries 
        channel="lightbox" 
        author_id="{logged_in_member_id}"
        entry_id="{segment_3}"
        dynamic="off"
        limit="1"
        }

    ... it works fine.

    My concern, is that I’ve never encountered a situation where BOTH segments from the URL were being applied to the Channel Entries dynamic behaviour. That seems to me that it might be a bug ... I mean, there’s no point filtering on BOTH the entry_id and the url_title ... they’re both unique identifiers.

    Not sure what’s going on! It certainly cost me a half-hour or so trying to track down why my single-entry page wasn’t displaying anything.

    Cheers,

    Brett

  • #4 / May 22, 2011 2:47pm

    Greg Salt

    3988 posts

    Hi Brett,

    This does seem a little odd. I’m unsure though whether this in intended behaviour or not so I’m going to check with the rest of the team. Thank you for you patience whilst we take a look at this. We’ll update this thread as soon as we can.

    Cheers

    Greg

    @Mark, thanks for helping out.

  • #5 / May 22, 2011 3:51pm

    Mark Bowen

    12637 posts

    As a quick note I’m fairly certain that 2.1.4 doesn’t exhibit this behaviour so perhaps you are using 2.1.3 Brett?

  • #6 / May 22, 2011 3:58pm

    Greg Salt

    3988 posts

    Hi Brett and Mark,

    You’re right Mark. That’s my fault for not checking!

    Brett, are you in a position to upgrade to the beta? If not, then this behaviour will be changed in the next stable release.

    Cheers

    Greg

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

ExpressionEngine News!

#eecms, #events, #releases