Recent Topics

[Fixed] [2.4.2] Problem with tag cloud (the one from core)

Thread started by , Sun Jun 8, 2008 10:55 – Last touched: Sun Jun 8, 2008 10:55
Started by , 06/8/08

Jun 8, 2008 10:55    

My b2evolution Version: 2.4.2

In tag cloud (the one include in the core), a tag could appear even if the article is not yet published;
Also, the number of posts (shows using mouse over) included articles which are not yet published (date in the future).
\blog\inc\widgets\widgets\_coll_tag_cloud.widget.php

Comment from:

Looks like a hiatus very close to a bug so I moved this.

--FH

06/09/08 @ 02:39

Comment from:

I found an other bug in tag cloud:
tags from draft/private/protected and so on are counts.
So the SQL request should be updated by adding AND POST_STATUS = 'published'.
_coll_tag_cloud.widget.php line 148:

PHP

$sql 'SELECT LOWER(tag_name) AS tag_name, COUNT(itag_itm_ID) AS tag_count
                          FROM T_items__tag INNER JOIN T_items__itemtag ON itag_tag_ID = tag_ID
                                      INNER JOIN T_postcats ON itag_itm_ID = postcat_post_ID
                                      INNER JOIN T_categories ON postcat_cat_ID = cat_ID
                         WHERE cat_blog_ID = '.$Blog->ID.' AND POST_STATUS = \'published\'
                         GROUP BY tag_name
                         ORDER BY tag_count DESC
                         LIMIT '.$this->disp_params['max_tags'];

I do not test it yet.

Next time I will try to check the date to avoid "future" post.[/php]

06/10/08 @ 22:41

Comment from:

I'll be heavily testing this query:

PHP

$sql 'SELECT LOWER(tag_name) AS tag_name, COUNT(itag_itm_ID) AS tag_count
                          FROM T_items__tag INNER JOIN T_items__itemtag ON itag_tag_ID = tag_ID
                                      INNER JOIN T_postcats ON itag_itm_ID = postcat_post_ID
                                      INNER JOIN T_categories ON postcat_cat_ID = cat_ID
                                      INNER JOIN T_items__item ON itag_itm_ID = post_ID
                         WHERE cat_blog_ID = '.$Blog->ID.' AND post_status = "published" AND post_datecreated < NOW()
                         GROUP BY tag_name
                         ORDER BY tag_count DESC
                         LIMIT '.$this->disp_params['max_tags'];

But not today ;)

Testing also involves seeing if a post is shown in this situation: a post has a tag so the tag is shown in the cloud. What happens if a post in the future has the same tag. Will it be shown in the list of posts that is the result of clicking the tag. There are more such combinations thinkable, the resulting list is generated somewhere else. So if some one feels like it, please help debugging this one.

The code presented above is error free.

Good luck

06/13/08 @ 05:42

Comment from:

a post has a tag so the tag is shown in the cloud. What happens if a post in the future has the same tag. Will it be shown in the list of posts that is the result of clicking the tag.

It works correctly: only the post with date < now are show when clicking the tag.

06/14/08 @ 14:58

Comment from:

But I still got a problem, the number of articles when mouse over the tag are not the right one.
For example on http://www.seven-passion.com/
if you mouse over tag "sexy" you will see "17 articles", but if you
click on it you will see only one article. The 16 others are published but with date in future.
I'm using the new SQL request with "post_datecreated < NOW()"

May be we must use 'post_datestart' instead

06/14/08 @ 17:06

Comment from:

I made some tests and I think that we must check date against post_datestart. So the SQL request should be:

PHP

$sql 'SELECT LOWER(tag_name) AS tag_name, COUNT(itag_itm_ID) AS tag_count
        FROM T_items__tag INNER JOIN T_items__itemtag ON itag_tag_ID = tag_ID
            INNER JOIN T_postcats ON itag_itm_ID = postcat_post_ID
            INNER JOIN T_categories ON postcat_cat_ID = cat_ID
            INNER JOIN T_items__item ON itag_itm_ID = post_ID
            WHERE cat_blog_ID = '.$Blog->ID.'
                AND post_status = "published"
                AND post_datestart < NOW()
            GROUP BY tag_name
            ORDER BY tag_count DESC
            LIMIT '.$this->disp_params['max_tags'];
06/14/08 @ 18:31

Comment from:

This seems to work:

PHP

$sql 'SELECT LOWER(tag_name) AS tag_name, COUNT(post_ID) AS tag_count
                          FROM T_items__tag INNER JOIN T_items__itemtag ON itag_tag_ID = tag_ID
                                      INNER JOIN T_postcats ON itag_itm_ID = postcat_post_ID
                                      INNER JOIN T_categories ON postcat_cat_ID = cat_ID
                                      INNER JOIN T_items__item ON itag_itm_ID = post_ID
                         WHERE cat_blog_ID = '.$Blog->ID.' AND post_status = "published" AND post_datecreated < NOW()
                         GROUP BY tag_name
                         ORDER BY tag_count DESC
                         LIMIT '.$this->disp_params['max_tags'];

the post_ID comes from T_items__item and is (should be) filtered with post_status and post_datecreated.

06/15/08 @ 01:32

Comment from:

I think post_datecreated, is the date when the post was "created" for the first time in the backoffice, not the date used to display it on a blog. I mean, if I use "edit" check box to make post with a date in the future, datestart would be changed accordly to my entry and datestart is used to select which post to display.

http://slamp.free.fr/b2evo/issueDate.png
The post above will be available tomorrow (June 16th), one minute after midnight

http://slamp.free.fr/b2evo/datestartVSdatecreated.png

06/15/08 @ 15:13

Comment from:

You are correct. I missed it. So forget my latest entry, yours is probably correct.
Now one more question that's bothering me: if we leave out "published" and/or replaced that by ("publshed" OR "protected") -don't forget the hooks- will it automagically show a different tagcloud to a different user depending on his status. Does it make sense to expand the thing to make it that way or is that overdone?

Good job Slamp, thanks for clarifying.

06/15/08 @ 15:50

Comment from:

if we leave out "published" and/or replaced that by ("publshed" OR "protected") -don't forget the hooks- will it automagically show a different tagcloud to a different user depending on his status.

I don't think it will be done automatically.

Does it make sense to expand the thing to make it that way or is that overdone?

Yes, it will be great to deal with published OR protected.

06/15/08 @ 20:30

Comment from:

Another interesting problem: If you choose more than one category for a post with tags, the number of posts for each tag will be equal to (or incremented about) the number of the post's categories. For example:
Create a post, assign it to three categories and give it some (unused) tags. In the tag cloud, the HTML title will say 3 instead of 1.

06/21/08 @ 18:22

Comment from:

Thanks Tblue,

Can somebody please test this case with this small alteration of the query?

PHP

$sql 'SELECT LOWER(tag_name) AS tag_name, COUNT(DISTINCT post_ID) AS tag_count 
                          FROM T_items__tag INNER JOIN T_items__itemtag ON itag_tag_ID = tag_ID 
                                      INNER JOIN T_postcats ON itag_itm_ID = postcat_post_ID 
                                      INNER JOIN T_categories ON postcat_cat_ID = cat_ID 
                                      INNER JOIN T_items__item ON itag_itm_ID = post_ID 
                         WHERE cat_blog_ID = '.$Blog->ID.' AND post_status = "published" AND post_datestart < NOW() 
                         GROUP BY tag_name 
                         ORDER BY tag_count DESC 
                         LIMIT '.$this->disp_params['max_tags'];

(The addition of DISTINCT is the only change)

Thanks

06/21/08 @ 22:15

Comment from:

Afwas wrote:

Now one more question that's bothering me: if we leave out "published" and/or replaced that by ("publshed" OR "protected") -don't forget the hooks- will it automagically show a different tagcloud to a different user depending on his status. Does it make sense to expand the thing to make it that way or is that overdone?.

Slamp wrote:

Yes, it will be great to deal with published OR protected.

I looked into this. If I have a protected post with a certain tag it will show in the aggregate page for that tag (I can see it, you can't - that's how it should be when it's protected). However due to the query it is not counted when hovering the tagcloud.
I have been playing with some code, but nothing worked. My guess is it's going to be difficult (needs to check who is the user and such before the query is executed). If I find a solution I will post it here.

To be more specific: this works:

PHP

post_status "published" OR post_status "protected" )

but it shows the tags from protected posts to the world.

06/22/08 @ 03:15

Comment from:

I see no further improvements without editing more files, so I committed this to cvs.

07/17/08 @ 04:02

Comment from:

perfect... then it is in the core for the next version.
1 thing less to remember.

07/17/08 @ 20:03

Comment from:

Just want to add something I found from v3.1-alpha HEAD.

If I change the separator to ", " the system cleans it up to just "," thus making all the tags not to break, creating a long horizontal line of continous text.

But if I change it back to " " (space), it works fine. Just that, if any other separator is used other than space, the system cleans up the trailing space.

03/11/09 @ 14:23
powered by b2evolution free blog software – This forum is powered by b2evolution CMS, a complete engine for your website.