Integrating Google Spreadsheets with WordPress

At WordUp Glasgow yesterday I showed a plugin I wrote to integrate data on Google Spreadsheet with a WordPress website.

The Use Case

To manage rotas within Adelaide Place Baptist Church we use Google Spreadsheet which several people have access to edit and keep up to date. This works for us as it’s easy to use and (almost) everyone has a Google account these days so passwords aren’t a hassle to remember.

I wanted to reuse this information on the front page of the website, to show who is leading worship and speaking on the next Sunday.

 

How does it work?

Install the following WordPress plugins: Zend Framework and Zend Gdata Interfaces.

In a plugin (or widget), to access the data from the spreadsheet:

//specify the URL for the spreadsheet
$url = "http://spreadsheets.google.com/feeds/list/[Big Long ID for the Spreadsheet]/od6/public/values?sq=current=true";
 
//instantiate new spreadsheetService object
$spreadsheetService = new Zend_Gdata_Spreadsheets();
 
//create new listFeed object
$listFeed = $spreadsheetService->getSpreadsheetListFeedContents($url);
 
//make use of the listFeed object
if ($listFeed) {
    $this->showThisWeek($listFeed,$pageurl);
}
else {
    echo $errorMsg;
}

And then to make use of the data:

function showThisWeek($feed,$pageurl) {
    $sunday = date('l jS F Y', $this->ukStrToTime($feed[0]['date']));
    $leader = $feed[0]["leader"];
    $speaker = $feed[0]["speaker"];
 
    echo("<div id='inline_apbcrota'>");
    echo("<h2>$sunday</h2>");
    echo("<ul class='thisWeek'>");
    echo("11am - 12.15pm <br />");
    echo("Worship leader: <strong>$leader</strong><br />");
    echo("Speaker: <strong>$speaker</strong><br />");
    echo("Coffee and tea afterwards<br />");
    echo("<a href='$pageurl'>Full WT Rota</a>");
    echo("</ul>");
    echo("</div>");
}
Categories: WordPress. Tags: , , . Permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">