Extending Joomla! Eventlist

Recently I extended the Eventlist extension for Joomla! to allow my netball club to add the results of fixtures to their site as well as the fixtures which are managed using eventlist.

It was actually much more straightforward than I expected so here’s a quick rundown of the changes:

  1. add two columns to the jos_eventlist_dates table to hold the scores
  2. add them to the class by editing components/com_eventlist/eventlist.class.php
  3. edit the sql statements in components/com_eventlist/eventlist.php and add in our new columns
  4. adding input boxes to the admin interface to administrator/components/com_eventlist/admin.eventlist.html.php, just a couple of input type=”text” boxes
  5. adding a new column to fixture lists in file components/com_eventlist/eventlist.html.php (not taking account of the lovely flexible width administration tool in the admin interface) and putting the results into each row

The scores default to 0-0 and show as 0-0 when there are no results – netball doesn’t really finish with no goals scored so its safe to assume that this means no result in this case! Last weekend our match finished 40-28 which is about average.

Hopefully this is interesting or useful to someone – if nothing else it will remind me what I changed next time I come to do something similar or further modify this!

PHP Abstract Podcast

I’m a regular listener to the PHP Abstract podcast from DevZone – and this week, I’m the star! Its a short podcast about PHP and Oracle, and you can find it here. Most of the comments so far seem to mostly revolve around my accent …

Women Together

Most people know that I’m active in the phpwomen community, women in technology is something that I really believe in but won’t start ranting about right now (or I’ll not get round to what I was going to say!).

Today I’m getting to grips with irssi which is a command-line IRC client. I was struggling with some quite dry documentation when I came across this tutorial from Ubuntu Women which has really helped me to get sorted out.

Yay for the women :)

Textpattern To Serendipity

I’m planning on migrating this site to a new platform soon, I’ve been looking around for an alternative to textpattern. Textpattern has been great but I’ve kind of outgrown it. Its easy to use but a bit “fluffy” and it eats my code excerpts which is really annoying.

I’ve picked serendipity as my intended target, its very modular and uses smarty for templating which I like and am familiar with. And if its good enough for sara and davey then I expect I will get along with it just fine.

Meeting Serendipity

So I installed Serendipity, nice easy installer, and started to look in the admin panel. There was a button for “Import Data” … you say what kind of blog platform you are coming from, and enter your database credentials and it attempts to import your old data. So I kind of tapped in my details.

Literally five seconds later I was looking at a blog with my entire history in it. Its got comments, posts, categories and users. I’m blown away, its utterly fantastic.

Finishing touches

The import didn’t cover stuff like images, which will need a whole series of conversions and text replacement on the posts to get sorted, and it seems to have chewed on some HTML entities. Also textpattern uses a post body with an optional excerpt and serendipity uses post body with optional extended body which has done some weird things to the import. It doesn’t help that I did use excerpts for a while in textpattern and then stopped after complaints from people reading on feed readers.

I’m also procrastinating over a theme for the new site … obviously it will involve a very empty stylesheet and at least two shades of pink but I’m not quite there with it yet. Once I’ve converted my content then I’ll just stop fiddling and use what I’ve got I think. I’ll also post the conversion scripts once I’ve finished with them.

Finally I will have to put together a bunch of HTTP 301’s since serendipity won’t support having article titles as the only thing after the domain name on the URL. I’ll keep you posted :)

Seeing stderr from PHP exec()

Today I was using the PHP command exec() in a script, which runs whatever you pass to it as it you had typed it on the command line. Its possible to check both the output of the command and the return value, which I did since I wasn’t getting the results I expected.

When you look at the output of the exec call, it isn’t the same as what you would see on the screen when typing the command. PHP returns you the content from stdout, but if anything goes wrong it will go to stderr which PHP doesn’t provide.

Redirect stdout to stderr

To get around this problem I altered my call from this:


exec ('unzip '.escapeshellarg($filename));

to this:


exec('unzip '.escapeshellarg($filename).' 2>&1);

This collection of characters tacked on the end of the code tells the system to send output 2 (stderr) to the address of output 1 (stdout). And the upshot is that I started to see the error messages being returned by the unzip program.

Postscript

Not really relevant to my point but probably useful for reference – the actual problem was that unzip was returning 50 as its return value. This apparently means the disk is full, which it wasn’t.

What had happened was that I was unzipping a file in another directory and unzip was trying to place the contents into my current working directory rather than the one with the zip file in! I used the -d switch to unzip to direct the inflated files to the right place and this worked a treat.

Posting with images in Joomla!

The other day I was helping someone post to a website that I set up using Joomla! , and thought that others might find this tutorial helpful.

Start with the “Media Manager” button on the front page. This is so you can add all the images. Directories can be added here to manage images – I found that adding images to subdirectories inside the “stories” folder made them available to add to articles.

To add the images, use the “choose” button next to the “file upload” box. Choose your image and then click on the “upload” picture above (not an obvious place for a button, I know!). Your picture will appear in the grid below. Upload all the images you like.

Now you can publish them to the site. Click on “home” in the top left and then “Add New Content”.

Start by unticking the “published” box on the right hand side of the screen, this means you can work on it as much as you like before it appears on the site, and it is safe to use the “Save” button at the top without it being visible online yet.

Not far to go now – just dropping those images into a story. Click on the images tab on the right hand half of the screen, and use the subfolders drop down box to find your folder. These will be listed in the “gallery” box. Add these images to the “Content Images” box by selecting them in the gallery box and clicking the arrows. The order in which the images are listed in the content images box is the order in which the images will appear on the page … either add them in order or just add them all and use the up/down buttons to get them straight.

Now give the article a name and put it into a section. Write what you want to in the “intro box”, and when you are ready to add the next picture, click on the “insert picture” tab. This is less confusing than it sounds, use the “preview” button at the top to keep track of what is actually happening.

When you are finished, choose the “Publishing tab” in the right half of the screen and tick the “published” and “front page” boxes. If you want to save it at any point, or it checking before it goes live, don’t tick these boxes. Either way, make sure you use the “Save” button at the top.

Hope that helps someone.

9 Steps to PHP Documentation Heaven

  1. Download PHPDocumentor and uncompress it into a directory inside your web root.
  2. Access the web interface by going to phpdoc.php in the newly extracted directory
  3. Enter the directory you would like to document
  4. Enter the directory the output should appear in (this needs to exist and be writable by the user your web server runs as)
  5. Choose a template! My favourite is the HandS one, but there are others and you can create your own later on
  6. Press the create button
  7. If your code wasn’t already documented correctly then there might not be a lot to see at this point. Go to the PHPDocumentor tutorial to find out how your commented code can become shiny documentation you can use to blind your manager with science to empower knowledge-sharing within your team
  8. Regenerate the documentation
  9. Get the rest of your team to comment their code correctly

Now repeat steps 8 and 9 many times until you have beautiful documentation.

PHP Best Practices

There’s a new thread started over at phpwomen.org about best practices for programming with PHP, which will make interesting reading for anyone looking to improve their skills. I’ve been really brave and contributed one of the articles, PHPDoc: Comments are your friends.

People are all contributing a little knowledge about the area they feel comfortable with and even at this early stage the results are impressive!

PHP Throwdown Icon

As you may remember we participated in the PHP Throwdown a while ago. Well Elizabeth has sent out the icons to competitors who successfully got through the 24 hours and submitted something which vaguely conformed to the rules. You can see ours on the left :)