Oct 6, 2009
Creating a Blog Topics Directory in WPMU 2.8 + BuddyPress 1.1

I recently set up an installation of WordPress MultiUser (WPmu) + BuddyPress for the History Department where I work. We have a number of different user groups on the site, including Courses, Workshops, and Projects. Eventually we will also have Personal sites (for students, staff, and faculty in the dept.) and perhaps some small organizations and campus groups. Right now the site is small, so it would be reasonable to manually create and maintain a topical directory. As the site grows, however, this could become a burden to say the least. Nobody likes to do that kind of crap – not even graduate assistants. So with the help of an outdated plug-in and a couple of tiny hacks, I easily created a directory of Blogs by Topic so I never need to hand code the directory. Read on to find out how.
To begin with, I’m using Deanna Schneider’s very handy Blog Topics For WPMU. Basically, Blog Topics creates a field in the relevant Settings, Registration and BuddyPress areas in which your users choose from a drop-down of admin-defined topics. They cannot create new topics, they must use the ones you set, so keep that in mind. The Site Admin can manually set the Topic for any blog at any time; this might be necessary if you already have a handful of blogs on your site (or you could demand that your users do it themselves because this is all about being lazy). Some users might misfile their site in the wrong category, but you can always go in and edit any blog’s Topic; they probably won’t even notice.
You might be wondering why I would write a tutorial for installing a plug-in. Well, I’m not sure if the plug-in code has some deprecated elements or if it just doesn’t play nice with the new BuddyPress theme structure, but it’s actually a bit more complicated than just installing the plug-in. For whatever reason, the documentation for this plug-in is pretty weak and some of it just doesn’t seem to work without some tweaks. That’s where I come in to sum up my hours of frustration with what now seems like an obvious process.
Here’s the drill…
- Install the plug-in in your wp-content/plugins folder and activate it on your parent site. The plug-in comes with a nice little widget for your MU child sites, but it won’t help you here so consider it optional.
- Inside the wp-content/plugins/blog-topics directory, you will find the file cets_blog_topics_page.php (a WordPress page template). Copy this file to the root of your site’s parent theme file. If you are using BuddyPress 1.1, that means themes/bp-sn-parent.
- Now, take that file and mess it all up according to the instructions below. Unfortunately, in the plug-in’s current state (v. 0.3.2), the default file just doesn’t work, but after digging around in the code, I found some functions that work quite nicely and can be easily integrated into your BuddyPress directories. Again, you will need to save this to the root of your theme.
- Create a page called Blog Topics Directory (or whatever) and apply the Blog Topics Page template you just created.
< ?php /* Template Name: Blog Topics Page */ ?> < ?php get_header(); ?> <div id="content" class="narrowcolumn"> < ?php do_action( 'bp_before_directory_blogs_content' ) ?> <div class="page" id="blog-page"> < ?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h2 class="pagetitle">< ?php the_title(); ?></h2> <!--using anchors for long lists, or you could use something fancier to browse topics--> <ul id="topic-list"> <li><a href="#topic1">Topic 1</a></li> <li><a href="#topic2">Topic 2</a></li> <li><a href="#topic3">Topic 3</a></li> <li><a href="#topic4">Topic 4</a></li> <li><a href="#topic5">Topic 5</a></li> </ul> <!--add the numeric Topic ID according to the models below--> <!--topic1--> <a name="topic1"></a> <h2 class="pagetitle">< ?php echo cets_get_topic_name('1') ?> Blogs</h2> < ?php echo cets_get_blogs_from_topic_id_html('1'); ?> <!--topic2--> <a name="topic2"></a> <h2 class="pagetitle">< ?php echo cets_get_topic_name('2') ?> Blogs</h2> < ?php echo cets_get_blogs_from_topic_id_html('2'); ?> <!--topic3--> <a name="topic3"></a> <h2 class="pagetitle">< ?php echo cets_get_topic_name('3') ?> Blogs</h2> < ?php echo cets_get_blogs_from_topic_id_html('3'); ?> <!--topic4--> <a name="topic4"></a> <h2 class="pagetitle">< ?php echo cets_get_topic_name('4') ?> Blogs</h2> < ?php echo cets_get_blogs_from_topic_id_html('4'); ?> <!--topic5--> <a name="topic5"></a> <h2 class="pagetitle">< ?php echo cets_get_topic_name('5') ?> Blogs</h2> < ?php echo cets_get_blogs_from_topic_id_html('5'); ?> < ?php endwhile; endif; ?> </div> < ?php do_action( 'bp_after_directory_blogs_content' ) ?> </div> < ?php get_sidebar(); ?> < ?php get_footer(); ?>
You could probably find any number of ways to integrate this into your theme’s Blog Directory. Although I might eventually change it, right now, I’ve just added a link to the Blog Directory sidebar which users can… use… to Browse Blogs by Topic. If it helps, here’s a link to the site where this code is being used. Again, it needs some tweaking but this should get you started. Hope this quick fix has helped.
If you’re wondering why this post has a giant image of Brak (among other notable “buddies”) at the top, or if you just need a break from all this BuddyPress nonsense, you might need to listen to this…
Great write up and tip, but I have a couple questions.
1. Following your link above, I don’t see a “Browse Blogs by Topic” area. Have you turned off this functionality?
2. Have you alerted Deanna Schneider of the issue with her plugin and BuddyPress? I’ve had an opportunity to communicate with her a few times regrading her plugins and she’s usually quick to correct any issues.
p.s. I found your post via a Google Alert for “wpmu”.
Hi Adam, thanks for the comment. To answer your questions…
1. For the time being, I just linked it in the sidebar here: http://clevelandhistory.org/blogs (it goes to http://clevelandhistory.org/topics/)
2. No, I have not alerted Deanna. I figured BuddyPress 1.1 just came out so it might take some time for an update (if indeed BP changes are to blame). You are correct though that contacting her would be a good idea. I literally just discovered and implemented the plugin (and then wrote the post) yesterday so I hadn’t even considered it. Good lookin’ out.
Yep, she;s pretty good about updating. As far as I know, she did not develop this for use on buddyPress – just WPMU. I’ve used it plenty of times with no issues.
(and in the mu-plugins folder, not the plugins folder)
Hey man,
Jim Groom just published another piece on WPMU. http://bavatuesdays.com/faq-for-universities-interested-in-wpmu/ Since you’re not on g chat today, I’ll leave the address here. Check it out!
I just to know if the accompanying graphic is an EB original. If so, dude, you have arrived. Genius.
I just WANT to know…
Still trying to grasp my head around the whole “topics” thing.
So during the blog registration process, the user gets to select a few “topics” that the admin sets up.
In your example, you made the following “topics”:
-Courses
-Workshops
-Projects
-Organizations
-Personal
Basically, it’s another way of categorizing your blogs on WPMU, correct?
I’ll have to play with this later… some screenies of the admin area and blog registration page would have been nice.
Hi,
Great article! I would like to repost this blogpost on my BuddyPress tutorial site, because I think it’s a very useful tutorial. Could you please let me know if you agree with this (it’ll be a guest post from you of course!)
Greetings,
Bowe