Tag Archives: wordpress

Integrating CakePHP with bbPress – Part 1

23 Aug

I’ve been working on StatForge.com for the past few days and one of the community features I want to integrate is a forum.  Rather than go for something bloated like phpbb or vanilla, I decided to go with bbPress from the makers of Wordpress.

This is the first of a 3 part tutorial on how to integrate bbPress with CakePHP 1.2.x.  When complete, these 3 tutorials will accomplish:

  1. Integrating bbPress in a sub-folder (not a subdomain) of your cake install
  2. Integrating user registration – when a user registers through your cake application they are automatically registered in bbPress. (UPDATE: part 2 here)
  3. Integrating the login – when a user is logged in via the cake application they are automatically logged in in bbPress.

Part 1 – Integrating bbPress in a sub-folder (not a subdomain)

It may be personal preference, but I’m not a big fan of subdomaining parts of an application.  There are definitely legitamite technical reasons to do so, but when I can get away with it, I try to use subfolders, i.e. http://statforge.com and http://statforge.com/forum/.

There’s a small hurdle here since CakePHP wants to ReWrite all your paths (if you’ve installed it in your domain root), but it’s easy to overcome.  Find the .htaccess file in the root of your cake install.  It should look like this:

   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]

This is rewriting all of your requests to the webroot folder. Assuming you want to install bbPress into a subfolder called forum (i.e. http://statforge.com/forum/) the change this .htaccess file to the following:

   RewriteEngine on

   RewriteCond %{REQUEST_URI} ^/forum/(.*)$
   RewriteRule ^.*$ - [L]

   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]

This simply reads – if the Request starts with /forum/ pass it through normally. If not, let Cake handle it. The only limitation here is that you cannot have a controller named ‘forum’ in your cake application.

That’s it – you should be able to drop a fresh bbPress install into the /forum subfolder and access it normally without Cake interfering.

I’ve already integrated the user registration between my CakePHP install and my bbPress install, but I’ve gotta run for the time being. Hopefully tomorrow I’ll throw up part 2 – it’s a bit more complicated. (UPDATE: part 2 here)

Google Reader Shared Items in WP RSS Widget

22 May

I just added a default RSS widget to one of my sidebars and noticed that the links weren’t functioning correctly. The source of the RSS feed is my google reader shared items and I think the format in which google sends the information is different than a normal RSS feed? I don’t know enough about them to be sure. All I know is that for some reason the link to the articles and the link to the sources of the articles are being concatenated together in the widget links.

Here’s a small 2-line fix I came up with if you’re familiar with php and the wordpress framework (version 2.5+).

In your {wp home}/wp-includes/widgets.php find the function wp_widget_rss_output(…). The first foreach() loop in the function should be foreach ($rss->items as $item ) { … Directly after the open curly brace, place these two lines of code:

$parts = explode(‘http’,$item['link']);
$item['link'] = ‘http’.$parts[1];

Voila – that fixed the problem for me. All it does is explode the link string by the delimeter ‘http’ and rebuild the link using the first part. It’s not a very extensible solution though, so I would only use it if you just want to use a google reader shared items feed for the source of an RSS widget.