bsuite Tags Where You Want ‘em
April 12th, 2007 by Roderick RussellBack in late January when I ported my blog over to WordPress and began using my friend Casey’s bsuite plug-in, I ran into an issue involving excerpted entries on the index page and the inability to display tags as a result. I needed a solution, couldn’t find one, so I wrote one. Below you’ll find the original email that I sent to Casey detailing the issue as well as the solution. I post it here in the event that others are interested in a solution as well.
Casey,
I’ve just ported over to WordPress and after getting all else up and running, installed your bsuite plug-in. I’m enjoying it very much, especially the new tag features.
The problem that I ran up against, however, was this: I am using the Post Teaser plug-in to excerpt my entries on the main index page - I tend to be long-winded and don’t want to force people to scroll forever to scan the posts. I do want tags on my primary index page for search engine and technorati indexing though, and as you know, your tag functions are hooked into and appear at the end of the_content, which is all after my excerpt, so tags don’t show up on the index page!
I searched forever and tried all sorts of hair-brained schemes to get my tags to appear despite calling the_excerpt, all to no avail. Well, I did get it working in a few different ways, but none that I was truly happy with. So, I took it upon myself to write a separate function that I can call, outside of the hooks and wherever I like, to do exactly what I need and, most importantly, where I need it.
Please forgive me if I’ve missed some exceedingly obvious means by which to do exactly what I’m describing, already built into bsuite. And if such a solution does exist, please share it!!!!!
But if such a solution doesn’t exist, then the following will work. Here’s what I did.
—–Fetch Just Tags From Bsuite - Put ‘em anywhere you like—–
First, as this is a separate function and not a plug-in, you have to enable the my-hacks.php support in the Miscellaneous Options tab of the admin interface (it’s labeled "Use legacy my-hacks.php file support"). You can of course simply paste the content of the function anywhere you like throughout your template, but I prefer to keep my functions separate, localized and organized. If you’re not against modifying source, it could be pasted into the bsuite.php file itself as well.
Now you actually have to have a my-hacks.php file in your root. Create the file, put the following contents in it and copy it to the root of your blog on your server.
<?php
function just_tags_from_bsuite()
{
echo ‘<table width="450"><div id="sidebar_section"></div>’;
/*This is just a table and bar that I print for my own aesthetic formatting.
Change it how you see fit.*/
//Get the entire post content
$whole_content=get_the_content();
//Generate the tag html with bsuite
$tag_content=bsuite_gettags_from_content($whole_content);
//convert the returned array into a string
$cond_content=implode(" ",$tag_content);
/*We’re going to divide the post from the tags now,
so set the delimiter to separate by.*/
$explode_delimiter=’<p class="bsuite_tagblock"’;
//Do the divide
$content_divided=explode($explode_delimiter, $cond_content);
/*Print the tags with appropriate html, and trim mysterious
"Array" string off end. Where did that array come from?*/
echo $explode_delimiter.trim($content_divided[1],"Array");
echo ‘<div id="sidebar_section"></div></td></tr></table>’;
//There’s that bar again… Change to whatever you want, or remove.
}
?>
Now, you can call the tags from any page you like from anywhere inside your template. To do so, open up your template file (i.e. your index template, archive template, et. al.) and place the following line anywhere that you want your tags to show up within The Loop:
<?php just_tags_from_bsuite(); ?>
Voila! I’ve tested this on every template page that I have, both with the_excerpt() called and without, as well as on pages that contain nothing more than a title. Be it your main index, archives, search or some specialized page, this will allow you to post your tags anywhere that you see fit without the worry of what hooks are firing where and when.
So in sum:
1.) Enable my-hacks.php support.
2.) Create my-hacks.php, paste the just_tags_from_bsuite() function inside and copy file to the server (root of blog)
3.) Insert the function call in any template page, anywhere within The Loop that you want your tags to appear.
On a personal note, between you and me, I’ve just installed WordPress a couple days ago and have virtually no experience with it, and only quickly hacked through your code (which thankfully is well documented inside), so perhaps I’ve missed something obvious, perhaps you already have a way of doing this, and perhaps my code sucks. I did pick up an extra array somewhere along the way that I had to drop out of there, so who knows… But I do know that it works, and it’s now easy.
Please let me know if you’ve got a better way, and if not, then perhaps others could use this little hack too.
All my best,
-Roderick
tags: casey bisson, maison bisson, php, post teaser, bsuite, indexing, tags, technorati tags, the_content, the_excerpt, worpress plug-ins






April 16th, 2007 at Apr 16, 07 | 9:48 am
Sweet! I’m glad the plugin was remixable like this.
I’ve been hard at work on a ground-up rewrite and rethink of how bsuite works that includes the ability to put tags and related posts whereever you want them, as well as support for machine tags and a whole new stats tracking plan.
In the meantime, I’ve released a bug fix version of bsuite2 here:
http://maisonbisson.com/blog/post/11613/
April 25th, 2007 at Apr 25, 07 | 10:44 am
Lately Casey has been so busy carpetbagging that development on bsuite has slowed down quite a bit… Thanks for figuring this out… I’ve been dealing with some similar problems with my geo mashup plugin putting the location URL below the suggested reading box. I may have to try out this workaround.