Recent Topics

1 Jun 08, 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

2 Jun 09, 2008 02:39

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

--FH

3 Jun 10, 2008 22:41

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:

		$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]

4 Jun 13, 2008 05:42

I'll be heavily testing this query:

		$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

5 Jun 13, 2008 20:30

I will help you debugging.

6 Jun 14, 2008 14:58

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.

7 Jun 14, 2008 17:06

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

8 Jun 14, 2008 18:31

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

		$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']; 

9 Jun 15, 2008 01:32

This seems to work:

		$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.

10 Jun 15, 2008 15:13

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

11 Jun 15, 2008 15:50

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.

12 Jun 15, 2008 20:30

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.

13 Jun 21, 2008 18:22

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.

14 Jun 21, 2008 22:15

Thanks Tblue,

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

        $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

15 Jun 22, 2008 00:59

Thank you, it works now. :)

17 Jun 22, 2008 03:15

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:

( post_status = "published" OR post_status = "protected" )


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

18 Jul 17, 2008 04:02

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

19 Jul 17, 2008 20:03

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

20 Mar 11, 2009 14:23

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.


Form is loading...