Posts Tagged "PHP"

Update: As of BuddyPress 1.1 this can be done via the wordpress aministration area. You can find this in BuddyPress > General Settings on the left side menu.

Those that use BuddyPress along with their WordPress MU installation may have found some limitations with the xprofiles. BuddyPress Devs have improvements listed as an upcoming feature, but in the meantime some things need to be fixed NOW!

One particular feature I needed to get round was the fact that you can’t change the default “Name” field. Whilst very common to have this as a field in most installations, we should at least be able to edit the field names the user sees, but unfortunately this is not so.

In a nutshell…

Google recently launched it’s version of social networking… by tying the sites you visit together via one universal, open platform.

The advantages of adding this feature to your site means that people can join your site by simply clicking one button and signing in using their Google or any OpenID account. This then allows the user’s friends on Google to see they joined your site, making a potential viral marketing oportunity. Not only that, Google Friend Connect supplies you with various gadgets that you can place around your site (e.g. the toolbar you see at the bottom of this blog).

There is much debate about the __autoload function introduced in PHP5. I personally love it as all those requires, includes etc. made programs quite messy, and frankly annoy me if you create loads of pages that keep on requiring the same classes.

The one fault __autoload has though is that Exceptions cannot be thrown, and that to me would give potential for some great degradeablity.

Thankfully, there are a few ways of hacking the autoload function so that it does throw an Exception. The most common way is to create a class with the class name the autoload function is looking for using the eval() function, and then throw an exception once autoload is happy.

Memcache is a caching mechanism for PHP which speeds up access to data by storing it in the RAM. Memcache runs as a server in a similar fashion to a database, except that data is not persistent in the long term. The great thing about Memcache is you don’t need to recompile php. Here’s some instructions on how to install and set it up.

Very simple bit of PHP to add to the top of your script if you want to password protect something. I wouldn’t reccommend this for larger bits of software, but if you have a simple script or page that you don’t want people to access, try the following:

I needed to grab a couple of new blog entries on a website’s wordpress blog area, and put it on a non-wordpress home page. I ended up making a PHP 5 class that did the job for me. Very simple, no fancy stuff.

I then needed to get a load of youtube video posts on the same site from a specific account and had to make a list of that, with thumbnails etc. . I ended up tweaking the first class ever so slightly and lucky me, I had an easy feed reader.

The DOMDocument is a convenient way of manipulating an XML file. While this is for PHP, I’ve come across some great parsers for use on a business iphone using lib2xml but we leave that for another day. One issue I ran into was the fact that when loading an XML file, DOMDocument treats the tabs and spaces which make the XML readable as empty text nodes. This presents a problem when you try and traverse the DOM by using attributes like firstChild and nextChild. For example: