Cheers to WordPress

I have probably said it before but will say again … WordPress is great. I spend most of my day writing and reviewing code at work and is nice to be able to write in words for a change. 

Word press is built with PHP – I know PHP has it's critics and sure there is a lot of hacked together PHP scripts out there but I am sure there are is a lot of good code also. WordPress is it's real success story (sorry not a facebooker) in my opinion.

In the past I have dug into the code base and found it a little hairy (used to OOP) – this was years ago though. I don't know what it looks like now, and whatever about the code base the ui seems to be orgainzed very well.

WordPress is just so flexible and straight forward and is great fun. Not sure about using it for businesses to be honest – have been there before and I think eventually you out grow it. Small businesses should be fine!

Problems with permalinks in WordPress on Ubuntu

I’ve had problems with permalinks in the past on Ubuntu and always forget one thing or other so here is a set of instructions on setting up those pesky permalinks. This is what I have done in past but if you can think of anything else, please let me know.

1. Create a new “.htaccess” file in your root WordPress directory.

2. Enabling mod_write in the Apache2 server. Type:
sudo a2enmod rewrite

3. Open a terminal and type:
sudo chown -v :www-data “//.htaccess”

4. Also give write access to the file:
sudo chmod -v 664 “//.htaccess”

5. Restart the Apache:
sudo /etc/init.d/apache2 restart
We are all done with the command line prompt; you can close the command line window now.

5. Go into your WordPress admin screen. Click on settings, then on permalinks and select whichever permalink layout you wish. Hit Save button.

Master pages in PHP

One of the good things about  .NET is that you can you use master pages. A master page is basically a template page which you can use to control the layout of other pages. Its usefull to ensure consistency across all pages on a site and most importantly it cuts down on a lot of repetitive programming.

PHP does not support such a feature but its easy enough to achieve the same effect. The way I do this is by creating a PHP page called master.php. I fill out the HTML parts as normal and in the place which I want to have varying content between pages, I add PHP variables.

When implementing the inheriting pages later I define the same variables but also assign content to them. After the variables have been assigned content html, I import my master.php page.  Nice.

Here is an example:

The master page, Master.php

<html>

<head>..</head>

<body>….

<div id=”middle”>
<div id=”middleLeft”><?php echo $text; ?></div>
</div>

</body>

</html>

An a content page, about.php:

<?php ….

$text = “This is a good example”

include(“master.php”); ?>