The Radio ‘On Air’ Script

Over the past few months I’ve developing the One Media Group (OMG) website for Staffordshire University Students’ Union.

The theme was ‘out of the box’ from ThemeForest and what I’ve done is add some of the functionality and change how it looks a bit.

The main function that I wanted to add to the site was who was on air and how that was displayed on the site.

I’ve worked my good friend and colleague Christopher Smith for several years and what has become known to us as the ‘on air’ script has helped us both massively.

The basis of the script is a text file which contains each day’s schedule. Each line consists of the time the show is on air and the presenter/show name , all separated by pipes. A PHP file then reads this text file and uses the pipes to divide the information up and assigns it to a string which is printed. There are several different files which do different things; one to see what’s on air now and then ones to display a particular day’s schedule.

When we started using the script we would just simply include the relevant files where we wanted them, but now we both work with WordPress and wanted to integrate it a bit better.

Something I wanted to do was use some AJAX to update the on air information without the user refreshing the page. Christopher found the AJAX which the radio station he was working with used to update their now playing song. We modified it slightly and now on the OMG website it is used in the header to display the on air now and next show information.

My code is different from Christopher’s as I wanted to display it slightly differently. The AJAX is reloading a PHP file which has the listen and webcam button as well as includes for the on air now and next PHP files, which read the schedule text file. This file is reloaded on any OMG page every 60 seconds.

Now for the schedule page of the website. I didn’t want to include an iframe in a page entry (like I did last year for Cre8 Radio) as it wasn’t very tidy and was a pain to maintain! So Christopher and I worked together on creating a page template that we could apply to our schedule pages. All I did on the template was include the seven ‘day’ PHP files and styled them so they looked good.

To edit the text file that would contain all the on air information I wanted something that was easy and plain. So I installed CMS from Scratch in a directory and created a single text file that those with the client password could edit. It does take users outside of  WordPress to edit a single file, but I felt this was easier than trying to direct people to the theme editor page within WordPress (mainly because I didn’t want to give them Admin rights to do so!).

However, I wanted to see if there was anything I could add to this. On websites such as BBC Radio 1, where it tells you who is currently on air in the header, it’s also a link to their show page. What if I could do this as well in the header of the OMG website?

I dived back in to the PHP files which were figuring out what the on air text file meant. I was easily able to add another pipe for it to read, which would contain a URL to print. Originally the button span was printed in the file which the AJAX was reading, but I needed to change it so that the span was printed in the on air now PHP file. It was a bit messy for a while as I tried to figure out where things were being printed.

My next thought was ‘what if that presenter/show doesn’t have a page we can link to?’ This required much more work as I figured out what PHP function to use to see if a string was empty. I eventually used the empty function and told it that if it was empty to point the link to the schedule page. On the schedule page, the show links would also display in the presenter and show names.

Another use that I hope to use the show links for is when the news and sports shows are on, is that the link can point to the news and sports pages. Also when we cover Varsity in a couple of months time, those links can all point to our live blogs and Varsity homepage.

  

That’s pretty much what I did over Christmas to enhance the OMG website! I will also be using much of that code and integration for the Cre8 Radio website when it comes back on air in May/June.

All of these changes will be activated once the new branding comes in (which should be within a week or two of writing this).

7 Comments Short URL , , , ,

7 Responses to “The Radio ‘On Air’ Script”

  1. G 16th March 2012 at 17:23 #

    Hi,

    I really like what you’ve done. Is it possible to share the code with me? I’ll like to do something similar. THank you.

    • Oliver 16th March 2012 at 17:33 #

      My plan is to make it into something that people can download, with some documentation and usage examples. However I must discuss this with the co-creator beforehand.

      • G 16th March 2012 at 18:06 #

        Ok. Thank you

  2. Ryan 14th November 2012 at 12:17 #

    Any idea when this might be released?

  3. blog.duncraft.com 1st October 2013 at 22:43 #

    Thanks for your marvelous posting! I quite enjoyed reading it, you will be a great author.
    I will make certain to bookmark your blog and will eventually come back later on.
    I want to encourage that you continue your great
    writing, have a nice morning!

    my web blog: CD Key kaufen; blog.duncraft.com,

  4. Danny 1st December 2014 at 01:04 #

    Will you ever put the code up for download are for sale?

Trackbacks/Pingbacks

  1. Community Radio Websites – The Good, The Bad and The Dysfunctional | Olver.me - 1st February 2012

    […] of their website. I’ve even teamed up with a good childhood friend of mine to develop the Radio ‘On Air’ Script, which is now used at three radio stations in the […]

Leave a Reply