bstat Search Cloud
Casey over at MaisonBisson has developed a sweet WordPress plugin called bstat. I’ve been using it since I installed WordPress as my blog. Well, one thing that is missing from the plugin that I decided I wanted was a search cloud (like a tag cloud, only for incoming searches)… I recently created a tag cloud on MasterWish so decided to use that. Here’s the function.
Special Functions
- bstat_search_cloud
Usage:
bstat_search_cloud(post_id, maxresults, days, starting_font_size);
- post_id is the post_id for the story, usually provided by a WP variable. A value of 0 is used for grabbing all search terms from any post
- maxresults is the number of search terms you wish to retrieve
- days is the number of days back to look
- starting_font_size is the starting font size of the smallest search term
Example:
<h3>All incoming search terms for this post</h3>
<small>< ?php bstat_search_cloud(0,50); ?></small>
Discuss This Article
|
|
20 Responses to “bstat Search Cloud”
-
Casey
Posted: Nov 14th, 2005 at 2:30 pm1 -
Jamie
Posted: Nov 28th, 2006 at 2:46 amReply to this comment.Hi
This is just what I am looking for, but how do I add it to my blog.
Some help would be great.
Jamie
2 -
Jack
Posted: Dec 22nd, 2006 at 10:15 pmReply to this comment.is it add
‘;
$request=”select num from (select * from (select distinct(ref) ref,count(ref) num from wp_bstat_refs WHERE ref not like ‘http%’ and ref not like ‘www%’ AND bstat_date > ‘$date’ $post_id group by ref) t1 order by num desc limit 0,$maxresults) t2 order by num asc limit 0,1″;
if($row=$wpdb->get_results($request))
{
$divisor=ceil($row[0]->num/$starting_font_size);$request = “select * from (select * from (select distinct(ref) ref,count(ref) num from wp_bstat_refs WHERE ref not like ‘http%’ and ref not like ‘www%’ AND bstat_date > ‘$date’ $post_id group by ref) t1 order by num desc limit 0,$maxresults) t2 order by ref”;
$rows = $wpdb->get_results($request);
foreach($rows as $row)
{
$tag=array(
‘ref’=>$row->ref,
‘num’=>$row->num
);$rows2 = $wpdb->get_results(”SELECT * FROM wp_bstat_refs WHERE ref=’”.$tag['ref'].”‘”);
$tag['link']=get_permalink($rows2[0]->post_id);
$tag['size']=10;
$tag['size']+=(floor(($tag['num']/$divisor)/$starting_font_size)*2);
$tag['size']=($tag['size']>30)?30:$tag['size'];
$tag['ref']=str_replace($search,$replace,$tag['ref']);
$text.=’‘.$tag['ref'].’ ‘.”\n”;
}//end foreach
$text.=”;
echo $text;
}//end if
}//end bstat_search_cloud
?>to bsuite code?
4 -
Jack
Posted: Dec 22nd, 2006 at 10:41 pmReply to this comment.i have the error after that..
5 -
robinson
Posted: Jul 31st, 2007 at 8:24 amReply to this comment.I’ve been looking for bstat but I can’t find a valid url. including the one at MaisonBisson… is there any one who knows the valid url for downloading the bstat? if there’s a tutorial it would be very help full…. thanks..
6 -
Budi S
Posted: Sep 14th, 2007 at 10:12 pmReply to this comment.Can you gi give me bstat.zip ….
because i have download but it can’t be opened …
thx8 -
peter
Posted: Sep 3rd, 2008 at 10:03 pmReply to this comment.hi Matt, I have install latest bsuite and activate it. but I do not know how and where to add “bstat_search_cloud” and “All incoming search terms for this post
” . can you give me detail steps, thank very much9 -
GadgetHeat
Posted: Oct 2nd, 2008 at 12:22 amReply to this comment.Hi Matt
I am trying to adjust your code for bsuit4 so that I can show the incoming search cloud in my posts but am having no luck. I have adjusted you syntax as below but I get the following error
‘WordPress database error: [Unknown column 'post_id' in 'where clause']
select num from (select * from (select distinct(name) name,count(name) num from wp_bsuite4_hits_terms WHERE name not like ‘http%’ and name not like ‘www%’ AND post_id=1654 group by name) t1 order by num desc limit 0,50) t2 order by num asc limit 0,1′Can you please tell me where I am going wrong and prefferably how to fix it? My code is below:
<?php
function bstat_search_cloud($post_id, $maxresults, $days=365, $starting_font_size=9)
{
global $wpdb, $bsuit4_hits_table;
$search=array(’tag/’,'tags/’);
$replace=array(”,”);$date = date(”Y-m-d”, mktime(0, 0, 0, date(”m”) , date(”d”) - $days, date(”Y”)));
$post_id=($post_id)?” AND post_id=$post_id”:”;$text=”;
$request=”select num from (select * from (select distinct(name) name,count(name) num from wp_bsuite4_hits_terms WHERE name not like ‘http%’ and name not like ‘www%’ $post_id group by name) t1 order by num desc limit 0,$maxresults) t2 order by num asc limit 0,1″;
if($row=$wpdb->get_results($request))
{
$divisor=ceil($row[0]->num/$starting_font_size);$request = “select * from (select * from (select distinct(name) name,count(name) num from wp_bsuite4_hits_terms WHERE name not like ‘http%’ and name not like ‘www%’ $post_id group by name) t1 order by num desc limit 0,$maxresults) t2 order by name”;
$rows = $wpdb->get_results($request);
foreach($rows as $row)
{
$tag=array(
‘name’=>$row-> name,
‘num’=>$row->num
);$rows2 = $wpdb->get_results(”SELECT * FROM wp_bsuite4_hits_terms WHERE name =’”.$tag['name'].”‘”);
$tag['link']=get_permalink($rows2[0]->post_id);
$tag['size']=10;
$tag['size']+=(floor(($tag['num']/$divisor)/$starting_font_size)*2);
$tag['size']=($tag['size']>30)?30:$tag['size'];
$tag['name']=str_replace($search,$replace,$tag['name']);
$text.=’‘.$tag['name'].’ ‘.”\n”;
}//end foreach
$text.=”;
echo $text;
}//end if
}//end bstat_search_cloud
?>Thanks
Saif10 -
GadgetHeat
Posted: Oct 3rd, 2008 at 6:59 amReply to this comment.Finnaly got this working (Yay me!) If anybody wants to know contact me via my website
11 -
GadgetHeat
Posted: Oct 3rd, 2008 at 10:05 pmReply to this comment.Finnaly got this working (Yay me!) If anybody wants to know contact me via my website
Finnaly got this working (Yay me!) If anybody wants to know contact me via my website
Finnaly got this working (Yay me!) If anybody wants to know contact me via my website
Finnaly got this working (Yay me!) If anybody wants to know contact me via my website
Hello,
it didn’t worked for you , you are still gettings errors.
-DS
Finnaly got this working (Yay me!) If anybody wants to know contact me via my website
Finnaly got this working (Yay me!) If anybody wants to know contact me via my website
Finnaly got this working (Yay me!) If anybody wants to know contact me via my website
12 -
GadgetHeat
Posted: Oct 4th, 2008 at 1:43 amReply to this comment.It is working fine. Look at the bottom of my individual posts. You will see incoming search terms linked to the post title.
The only problem I have left is excluding search terms which have key characters such as ‘\’. I need to escape these then everything will be perfect.
13 -
DS
Posted: Oct 4th, 2008 at 8:04 amReply to this comment.Nice job GadgetHeat , awesome !
It’s working fine …i was looking for posts where there wasnt’ any incoming searches…my bad.
Anway can you help me with this..i am struggling for this for last 2 weeks and haven’t done any progress. I have got bsuite plugin activated, and created a seprate function, then added that function into functions.php..but it doesn’t work .
Thanks !14 -
Urban
Posted: Oct 15th, 2008 at 7:36 amReply to this comment.Nice job GadgetHeat , awesome !
It’s working fine …i was looking for posts where there wasnt’ any incoming searches…my bad.
Anway can you help me with this..i am struggling for this for last 2 weeks and haven’t done any progress. I have got bsuite plugin activated, and created a seprate function, then added that function into functions.php..but it doesn’t work .
Thanks !Hi,
I was trying to contact you through your form on the website, but the page didn’t work, some php error… so I contacted an email address that I found on your website. Don’t know if it works.
Anyhow, can you help me with the solution? I’m stuck.
And did you solve the character issues? I for example have lots of articles containing the “-” character. Is this a problem? Or do I understand this wrong? Where is that character issue coming up?
15 -
Binh Nguyen
Posted: Oct 17th, 2008 at 1:03 pmReply to this comment.Thank you for this special function. I’m looking for something to do search cloud like yours.
But there is a problem. Does this still work for the current bSuite plugin? If not… do you have any fix?
Thanks.
16 -
Gautam
Posted: Oct 31st, 2008 at 10:05 amReply to this comment.@GadgetHeat: care to share what needs to be done.
Anyone else got it to work ?
Any lead would be of great help.
/G
17 -
pingback:
Posted: Nov 10th, 2008 at 10:47 amTop incoming search terms for this post - incoming search term tagging by Gautam H N Reply to this comment.[...] You can find Matts version here : http://borkweb.com/story/bstat-search-cloud [...]
18 -
Incoming Search Term Tagging
Posted: Nov 10th, 2008 at 10:50 amReply to this comment.I finally got “Top incoming search terms for this post” to work:
Folks who still are looking for it, can look at it at :
http://www.techbuzz.in/top-incoming-search-terms-for-this-post-incoming-search-term-tagging.php
19 -
Clara Lopez
Posted: Nov 12th, 2008 at 8:25 pmReply to this comment.xogc9iqasrwgxe4v
20



Good stuff. I’m marking it for inclusion in the next release.