Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Integration questions

In the interest of sharing what I’ve learned so far, let me describe what I want to do, and what I’ve accomplished so far.

1) I want to have a stand alone instance of bbPress running on my site that shows ALL the forums.

2) I want to embed a single forum into a wordpress blog (actually a wordpressmu blog– but there’s nothing mu specific about my work so far)

3) I want the forums to share the same DB, so if a topic is updated inside of my blog, I also see it updated in the standalone Forum.

4) I want to be able to essentially allow the bbPress template functions to work inside of a wp page or post… ideally I’d like to implement a simple function like “embedd_bbpress_forum()” on a page template and have it display a fully functioning bbPress instance in the page.

5) I want to use the chrome/theme from wordpress for the header, sidebar, footer, etc… but I also want to support the basic bbpress template structure as well.

So far I have this working about 90%…

What I’ve done is build a WP-plugin, that “includes” bbpress/bb-load.php. And implements a couple functions for embedding the bbpress instance in a page or post or where ever you call the embed functions.

Things that are working:

* forum home page

* topic pages

* new topic

* comments

* profile pages

* favorites

Things that aren’t working yet:

* ajax — none of the ajax stuff is working properly yet…

* some pages that use wp_redirect – because of how I’m embedding in wordpress, the headers are already sent before I have a chance to do the redirect, so… some functions that rely on this are reporting errors.

How I did this so far:

* declare GOBALS!!! – This is the biggest “sneaky trick” – basically, most of bbPress is implemented outside of a function or class context, and so the “local” variables on the bbPress pages are actually global in context. Since I’m wrapping these into a wp-pluing, I need to declare them as explicitly global. If I get all the globals right, then bbPress just works.

* turn off mod_rewrite support in bbPress… since I want my pages to get handled by WordPress, the URL needs to end at the same location of the wordpress page, this means that my forum page has a url something like:

http://mydomain.com/blog/forumpage/?command=topic.php&id=1

Notice I introduced the concept of the “command” parameter, that my plugin then uses as a dispatcher to “load” (include) the right bbPress file. MOSTLY bbPress will do the rest of it’s work from the URL params.

* Lots of filters – I’ve implemented several filters for URL remapping so that bbPress will override the standard link formation to point to my new embedded page urls

* A COUPLE HACKS – the only hard part I’ve had to hack so far relates to bbPress’s get_bb_location() function. This function appears to be a bit of bbPresses standard “dispatcher” which tells the rest of bbPress what type of page it’s supposed to be rendering. The only problem with this approach is that in my instance of the code base it does all this logic based on PHP_SELF, SCRIPT_FILENAME, or SCRIPT_NAME… which will be pointing to my wordpress files. I made a small change to add a new filter that allows me to pull out my command param and do the bb_location determination from that.

Has anyone else attempted this? Have they gotten further? Is there an easier way?

Mostly this isn’t a lot of code, it’s just discovering how to make it work and testing that everything works as planned.

Skip to toolbar