We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Category parameter and entry_id parameter not playing nice?

Development and Programming

Tad Ward's avatar
Tad Ward
41 posts
8 years ago
Tad Ward's avatar Tad Ward

I a blank template i have the following code:

{exp:channel:entries channel="blog" limit="4" category="36" entry_id="not 229"}
{title} - {entry_id}
{/exp:channel:entries}

Viewing the output, it shows a list of 4 entries however, entry 229 is still listed. Category 36 is a child category, if I do use the following in teh parameter “30&36;” It removes entry 229. 30 is the category_id and is a parent of category 36.

The template url was simply domain.dev/test

If i added a category_url_title such as ‘accessories’ as segment_2, the above still works. I am using Resource Router to basically remove the category URL indicator from the url structure.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Can you paste the queries from the output profiler? The one we’re looking for should start with SELECT t.entry_id FROM exp_channel_titles.

       
Tad Ward's avatar
Tad Ward
41 posts
8 years ago
Tad Ward's avatar Tad Ward

The two queries that closing match what you mentioned

SELECT DISTINCT(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 INNER JOIN exp_category_posts ON t.entry_id = exp_category_posts.entry_id INNER JOIN exp_categories ON exp_category_posts.cat_id = exp_categories.cat_id WHERE t.entry_id !=” AND t.site_id IN (‘1’) AND t.entry_date < 1477341547 AND (t.expiration_date = 0 OR t.expiration_date > 1477341547) AND t.entry_id != ‘229’ AND t.channel_id IN (4) AND exp_categories.cat_id = ‘36’ AND t.status = ‘open’ ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc LIMIT 0, 4

SELECT DISTINCT(t.entry_id), t.entry_id, t.channel_id, t.forum_topic_id, t.author_id, t.ip_address, t.title, t.url_title, t.status, t.view_count_one, t.view_count_two, t.view_count_three, t.view_count_four, t.allow_comments, t.comment_expiration_date, t.sticky, t.entry_date, t.year, t.month, t.day, t.edit_date, t.expiration_date, t.recent_comment_date, t.comment_total, t.site_id as entry_site_id, w.channel_title, w.channel_name, w.channel_url, w.comment_url, w.comment_moderate, w.channel_html_formatting, w.channel_allow_img_urls, w.channel_auto_link_urls, w.comment_system_enabled, m.username, m.email, m.url, m.screen_name, m.location, m.occupation, m.interests, m.aol_im, m.yahoo_im, m.msn_im, m.icq, m.signature, m.sig_img_filename, m.sig_img_width, m.sig_img_height, m.avatar_filename, m.avatar_width, m.avatar_height, m.photo_filename, m.photo_width, m.photo_height, m.group_id, m.member_id, m.bday_d, m.bday_m, m.bday_y, m.bio, md.*, wd.* FROM exp_channel_titles AS t LEFT JOIN exp_channels AS w ON t.channel_id = w.channel_id LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id LEFT JOIN exp_member_data AS md ON md.member_id = m.member_id WHERE t.entry_id IN (247,246,245,244) ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Yep that first one is the one we’re after. And it looks correct, specifically AND t.entry_id != '229'. You can see the entry ID’s reflected in the next query as well. So, doesn’t look like entry 229 is being displayed, as expected?

       
Tad Ward's avatar
Tad Ward
41 posts
8 years ago
Tad Ward's avatar Tad Ward

No, 229 is being displayed when it shouldn’t be.

I believe this could be an issue with parent and child categories.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Entry 229 is being displayed, on the page with the queries you copied above? I do not see how that is possible, the database isn’t retrieving any data for that entry ID.

WHERE t.entry_id IN (247,246,245,244)
       
Tad Ward's avatar
Tad Ward
41 posts
8 years ago
Tad Ward's avatar Tad Ward

Yessir, it sure is. It is the last entry in the list.

       
Tad Ward's avatar
Tad Ward
41 posts
8 years ago
Tad Ward's avatar Tad Ward

I did a search for that query you posted in your latest message and this is the result

SELECT DISTINCT(t.entry_id), t.entry_id, t.channel_id, t.forum_topic_id, t.author_id, t.ip_address, t.title, t.url_title, t.status, t.view_count_one, t.view_count_two, t.view_count_three, t.view_count_four, t.allow_comments, t.comment_expiration_date, t.sticky, t.entry_date, t.year, t.month, t.day, t.edit_date, t.expiration_date, t.recent_comment_date, t.comment_total, t.site_id as entry_site_id, w.channel_title, w.channel_name, w.channel_url, w.comment_url, w.comment_moderate, w.channel_html_formatting, w.channel_allow_img_urls, w.channel_auto_link_urls, w.comment_system_enabled, m.username, m.email, m.url, m.screen_name, m.location, m.occupation, m.interests, m.aol_im, m.yahoo_im, m.msn_im, m.icq, m.signature, m.sig_img_filename, m.sig_img_width, m.sig_img_height, m.avatar_filename, m.avatar_width, m.avatar_height, m.photo_filename, m.photo_width, m.photo_height, m.group_id, m.member_id, m.bday_d, m.bday_m, m.bday_y, m.bio, md.*, wd.* FROM exp_channel_titles AS t LEFT JOIN exp_channels AS w ON t.channel_id = w.channel_id LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id LEFT JOIN exp_member_data AS md ON md.member_id = m.member_id WHERE t.entry_id IN (246,244,240,229) ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc

As you can see, 229 is showing

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

So what changed between the first example you posted and now? It’s clearly not in the query you posted earlier.

       
Tad Ward's avatar
Tad Ward
41 posts
8 years ago
Tad Ward's avatar Tad Ward

Nothing has changed

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Something had to have, as those bits of the query are only influenced by tag parameters and the URL, and certainly wouldn’t change by simply refreshing the page. But I can help you drill down to it. What is the query right before that one?

       
Tad Ward's avatar
Tad Ward
41 posts
8 years ago
Tad Ward's avatar Tad Ward

No tag parameters have change. I double checked multiple URLs and its the same.

Perhaps I overlooked a query.

But this appears on the template no matter the URL

WHERE t.entry_id IN (247,246,245,244) & WHERE t.entry_id IN (246,244,240,229)

The list outputted is the 2nd WHERE statement

These are the full queries for both those statements

SELECT DISTINCT(t.entry_id), t.entry_id, t.channel_id, t.forum_topic_id, t.author_id, t.ip_address, t.title, t.url_title, t.status, t.view_count_one, t.view_count_two, t.view_count_three, t.view_count_four, t.allow_comments, t.comment_expiration_date, t.sticky, t.entry_date, t.year, t.month, t.day, t.edit_date, t.expiration_date, t.recent_comment_date, t.comment_total, t.site_id as entry_site_id, w.channel_title, w.channel_name, w.channel_url, w.comment_url, w.comment_moderate, w.channel_html_formatting, w.channel_allow_img_urls, w.channel_auto_link_urls, w.comment_system_enabled, m.username, m.email, m.url, m.screen_name, m.location, m.occupation, m.interests, m.aol_im, m.yahoo_im, m.msn_im, m.icq, m.signature, m.sig_img_filename, m.sig_img_width, m.sig_img_height, m.avatar_filename, m.avatar_width, m.avatar_height, m.photo_filename, m.photo_width, m.photo_height, m.group_id, m.member_id, m.bday_d, m.bday_m, m.bday_y, m.bio, md.*, wd.* FROM exp_channel_titles AS t LEFT JOIN exp_channels AS w ON t.channel_id = w.channel_id LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id LEFT JOIN exp_member_data AS md ON md.member_id = m.member_id WHERE t.entry_id IN (247,246,245,244) ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc

SELECT DISTINCT(t.entry_id), t.entry_id, t.channel_id, t.forum_topic_id, t.author_id, t.ip_address, t.title, t.url_title, t.status, t.view_count_one, t.view_count_two, t.view_count_three, t.view_count_four, t.allow_comments, t.comment_expiration_date, t.sticky, t.entry_date, t.year, t.month, t.day, t.edit_date, t.expiration_date, t.recent_comment_date, t.comment_total, t.site_id as entry_site_id, w.channel_title, w.channel_name, w.channel_url, w.comment_url, w.comment_moderate, w.channel_html_formatting, w.channel_allow_img_urls, w.channel_auto_link_urls, w.comment_system_enabled, m.username, m.email, m.url, m.screen_name, m.location, m.occupation, m.interests, m.aol_im, m.yahoo_im, m.msn_im, m.icq, m.signature, m.sig_img_filename, m.sig_img_width, m.sig_img_height, m.avatar_filename, m.avatar_width, m.avatar_height, m.photo_filename, m.photo_width, m.photo_height, m.group_id, m.member_id, m.bday_d, m.bday_m, m.bday_y, m.bio, md.*, wd.* FROM exp_channel_titles AS t LEFT JOIN exp_channels AS w ON t.channel_id = w.channel_id LEFT JOIN exp_channel_data AS wd ON t.entry_id = wd.entry_id LEFT JOIN exp_members AS m ON m.member_id = t.author_id LEFT JOIN exp_member_data AS md ON md.member_id = m.member_id WHERE t.entry_id IN (246,244,240,229) ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

And can I see the full template, please? You shouldn’t have both of those types of queries on the page with the channel entries tag in your original post.

       
Tad Ward's avatar
Tad Ward
41 posts
8 years ago
Tad Ward's avatar Tad Ward

The code in my opening post is all that is in the template.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Ok, you definitely have something going on that needs closer inspection. Extension perhaps, hard to say without looking. Can you drop in a support ticket so I can log into your environment and inspect first-hand?

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.