1 of 2
1
Tag Related Entries returns random results
Posted: 08 August 2008 06:44 PM   [ Ignore ]
Jr. Member
RankRank
Total Posts:  37
Joined  2006-12-07

I have this code on single entry template:

{exp:tag:related_entries weblog="community"  dynamic="off" orderby="random" limit="4"}
<ul>
<
li><a href="{homepage}detail/{url_title}/">{title}</a></li>
</
ul>
{/exp:tag:related_entries}

It is outside a weglog:entries tag and I have tried it with and without “dynamic="off".

The entries are all in the same blog.

The results returned - the “related entries” are totally random when viewing certain entries.

Example: I have three entries all tagged with the tag “insurance”.
each of the entries is only tagged with the one tag “insurance”

When viewing two of the articles, the related entries works perfecting displaying the 2 related entries
When viewing the third article, the related entries seems to show a random list

Using the Tag module in the Admin tool I look at the “insurance” tag and there are only 3 entries using that tag.

Profile
 
 
Posted: 10 August 2008 01:15 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

netbuilder,

Does that “third” entry have any other Tags? smile
If ANY Tag from that entry matches, the entry will display

 Signature 
Profile
 
 
Posted: 10 August 2008 01:45 PM   [ Ignore ]   [ # 2 ]
Jr. Member
RankRank
Total Posts:  37
Joined  2006-12-07

hi,
each of the 3 entries is only tagged once with the same tag.  I see this with many other articles as well.

I even looked at the DB tables and confirmed that each entry had only one tag, which is why I am mystified.

Profile
 
 
Posted: 11 August 2008 07:07 AM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

netbuilder,

Can I take a poke around in your CP? smile

PM me the details wink

 Signature 
Profile
 
 
Posted: 11 August 2008 07:12 PM   [ Ignore ]   [ # 4 ]
Jr. Member
RankRank
Total Posts:  37
Joined  2006-12-07

I think I found the problem:  If you have two entries—1 weblog entry, and 1 Gallery entry with the same ID the related entries query pulls both.

I turned on SQL debugging.
The entry being viewed is entry_id 201 - it is a weblog entry.
But there is also a gallery entry with the same id.

SELECT t.tag_idt.tag_name FROM exp_tag_entries te LEFT JOIN exp_tag_tags t ON t.tag_id te.tag_id WHERE t.site_id IN ('1') AND te.entry_id '201'

SELECT DISTINCT(te.entry_idFROM exp_tag_entries te LEFT JOIN exp_tag_tags t ON t.tag_id te.tag_id WHERE t.site_id IN ('1') AND te.type 'weblog' AND te.entry_id != '201' AND ( t.tag_name 'fishing' OR t.tag_name 'insurance')

The First SQL command does NOT specify the weblog ID so the code pulls all entries with ID 201. And it so happens that there is a Weblog Entry and a Gallery Entry with ID 201 that are both tagged.

The related entries tag includes the weblog name - is there something I can do in the tag to make sure I just get only entries from the named weblog, like using a weblog ID?

Profile
 
 
Posted: 12 August 2008 06:45 AM   [ Ignore ]   [ # 5 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

Hmmmm.. interesting.... wink

Which version of Tag are you using?
I know we’ve had Entry/Gallery ID collision issues in the past that we’ve fixed…

 Signature 
Profile
 
 
Posted: 12 August 2008 06:55 AM   [ Ignore ]   [ # 6 ]
Jr. Member
RankRank
Total Posts:  37
Joined  2006-12-07

Hi,
I’m running Tag 2.1.1 with EE 1.63.

If you notice the SQL on my previous entry it pulls two tags:

“Insurance” (which is the tag of the current entry being viewed)

“fishing” (which is the tag of a gallery entry with the same entry id)

Profile
 
 
Posted: 12 August 2008 07:13 AM   [ Ignore ]   [ # 7 ]
Jr. Member
RankRank
Total Posts:  37
Joined  2006-12-07

I just upgraded to tag 2.1.2 and see the same results…

Profile
 
 
Posted: 13 August 2008 07:42 PM   [ Ignore ]   [ # 8 ]
Jr. Member
RankRank
Total Posts:  37
Joined  2006-12-07

Just checking in - I need a fix for this as soon as you come up with something.

Thanks.

Profile
 
 
Posted: 14 August 2008 06:32 AM   [ Ignore ]   [ # 9 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

netbuilder,

I cannot at all reproduce this…

This is the code I’m using (on a Single Entry page) (with your criteria mentioned above)

{exp:weblog:entries}
{title}
<br />
{body}<br />
Tags{exp:tag:tags entry_id="{entry_id}" type="weblog" backspace="2" orderby="clicks" sort="desc"
<a href="{path='tags/tag'}{websafe_tag}" title="{tag_name}">{tag}</a>, 
{/exp:tag:tags}<br /><br />
<
br /><br />
{/exp:weblog:entries}

Related
:<br /><br />

{exp:tag:related_entries weblog="default_site" dynamic="off" orderby="random" limit="25"}
<p><a href="{path=tags/related_entries}{entry_id}">{title}</a></p>
{/exp:tag:related_entries}

 Signature 
Profile
 
 
Posted: 14 August 2008 07:42 AM   [ Ignore ]   [ # 10 ]
Jr. Member
RankRank
Total Posts:  37
Joined  2006-12-07

Do you have a gallery on the system with an entry that has the same ID as the weblog entry and is tagged? If not then I can understand it working perfectly.

I just did a test: I deleted the tag “fishing” from gallery entry 201 and magically all works perfect.

Here is the SQL: We are viewing a weblog entry but the SQL pulls TAGS FOR the WEBLOG ENTRY and a GALLERY ENTRY

First with Gallery Entry 201 (same id as the weblog entry) tagged with “fishing” - which has nothing to do with the current entry

SELECT exp_weblog_titles.entry_id FROM exp_weblog_titlesexp_weblogs WHERE exp_weblog_titles.weblog_id exp_weblogs.weblog_id AND exp_weblog_titles.site_id IN ('1') AND exp_weblog_titles.url_title 'florida-car-insurance' AND exp_weblogs.is_user_blog 'n'


SELECT t.tag_idt.tag_name FROM exp_tag_entries te LEFT JOIN exp_tag_tags t ON t.tag_id te.tag_id WHERE t.site_id IN ('1') AND te.entry_id '201'

This Step pulls the correct tag "Insurance" and INCORRECTLY pulls the page "fishing" which is the tag used on gallery entry 201 which has nothing to do with the current entry.

SELECT DISTINCT(te.entry_idFROM exp_tag_entries te LEFT JOIN exp_tag_tags t ON t.tag_id te.tag_id WHERE t.site_id IN ('1') AND te.type 'weblog' AND te.entry_id != '201' AND ( t.tag_name 'fishing' OR t.tag_name 'insurance')

Now here is the SQL after I remove the Tag from the Gallery Entry 201 - all works

SELECT exp_weblog_titles.entry_id FROM exp_weblog_titlesexp_weblogs WHERE exp_weblog_titles.weblog_id exp_weblogs.weblog_id AND exp_weblog_titles.site_id IN ('1') AND exp_weblog_titles.url_title 'florida-car-insurance' AND exp_weblogs.is_user_blog 'n'


SELECT t.tag_idt.tag_name FROM exp_tag_entries te LEFT JOIN exp_tag_tags t ON t.tag_id te.tag_id WHERE t.site_id IN ('1') AND te.entry_id '201'


This Step pulls just the Tag "Insurance" which is the tag used for the current Entry

SELECT DISTINCT
(te.entry_idFROM exp_tag_entries te LEFT JOIN exp_tag_tags t ON t.tag_id te.tag_id WHERE t.site_id IN ('1') AND te.type 'weblog' AND te.entry_id != '201' AND ( t.tag_name 'insurance')

The Second SQL Statement specifies just the ENTRY ID:

AND te.entry_id '201'

It seems like the SQL needs to specify the WEBLOG ID (if the entry being viewed is a weblog entry) or the GALLERY ID ( if the entry being viewed is a GALLERY Entry) and only pull both if the Related Entries tag includes both.
My Related entries tag only includes weblog="weblog_name" nothing about a gallery.

Profile
 
 
Posted: 14 August 2008 07:50 AM   [ Ignore ]   [ # 11 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18
netbuilder - 14 August 2008 07:42 AM

Do you have a gallery on the system with an entry that has the same ID as the weblog entry and is tagged?

I’ve tested this way, and I have no issue.

I will look further into this though smile

 Signature 
Profile
 
 
Posted: 22 August 2008 08:02 AM   [ Ignore ]   [ # 12 ]
Newbie
Avatar
Rank
Total Posts:  14
Joined  2008-01-28

Hi netbuilder, I’m experiencing the same problems. Did you manage to sort them out?
Carlo

Profile
 
 
Posted: 22 August 2008 11:38 AM   [ Ignore ]   [ # 13 ]
Jr. Member
RankRank
Total Posts:  37
Joined  2006-12-07

Hi,
No the problem persists. Pieman has checked out my system (logged into the cp) and confirmed all my settings are correct. Now he is waiting for the developers to look at it.

By reviewing the SQL the problem seems fairly straight forward so it should be an easy fix.

Profile
 
 
Posted: 02 September 2008 10:21 AM   [ Ignore ]   [ # 14 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  3356
Joined  2006-10-18

Hey guys,

I’ve sent (email) you both a fix for this issue. smile

Thank you very much for your patience.

 Signature 
Profile
 
 
Posted: 02 September 2008 01:08 PM   [ Ignore ]   [ # 15 ]
Jr. Member
RankRank
Total Posts:  37
Joined  2006-12-07

Hi Pieman,
I uploaded the new file - I wish it worked but now I just get nothing where the related entires should be…

When I switch back to the old file I get the same old results.

I tried clearing cache, etc.

Looking at the SQL, the variable weblog_id is blank so it appears the related_entires tag finds nothing and displays nothing. But I’m no expert so here is what I think is the relevant SQL for you experts to look at…

SQL output:

SELECT t.tag_idt.tag_name FROM exp_tag_entries te LEFT JOIN exp_tag_tags t ON t.tag_id te.tag_id WHERE t.site_id IN ('1') AND weblog_id '' AND te.entry_id '203'

SELECT exp_weblog_titles.entry_id FROM exp_weblog_titlesexp_weblogs WHERE exp_weblog_titles.weblog_id exp_weblogs.weblog_id AND exp_weblog_titles.site_id IN ('1') AND exp_weblog_titles.url_title 'florida-home-inspection' AND exp_weblogs.is_user_blog 'n'

Profile
 
 
   
1 of 2
1