Brew Recipes into Wordpress?

The Homebrew Forum

Help Support The Homebrew Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

puravida

Landlord.
Joined
Apr 30, 2010
Messages
749
Reaction score
0
Location
Stroud
(mods - wasn't sure where to post this one)

I'm looking for a way to easily import brew recipes from Beersmith into a wordpress blog rather than just copy and paste (formatting always looks rubbish)

Any suggestions??? :thumb:
 
That's a good question, and prompted me to have a bit of a mess around during my lunch break...

Since BeerSmith and quite a few other programs can export their receipe files in BeerXml format, it seemed to me that one of the simplest ways would be to just use an XSLT file to transform the BeerXml into HTML to include directly in Wordpress posts and pages.

It's a little bit of a faff to set up at first, but once it's configured and the XSLT is to your liking it should just be a matter of uploading new recipe files and including them in posts.

What follows was implemented on Wordpress 3.3.1, so may not work on previous versions (and may stop working in future ones).

There were a few minor problems I found along the way:

1) You can't immediately upload XML or XSLT files with the normal uploader.
Install the "PJW Mime Config" plugin. This allows you to add file types "xml" and "xslt" with MIME type "text/xslt". Once done you can upload files with those extensions.

2) We need something to do the XSLT transform.
Install the "Xslt Processor" plugin. This lets you include transformed XML in your pages and posts.

When editing the HTML of your post, you can include an element like this:
[XmlProcessor xml="wp-content/uploads/2012/02/Weiss-Weiss-Baby.xml" xslt="wp-content/uploads/2012/02/BeerXml.xslt"]

3) My files were in the wrong formats!
The BeerXml file needed editing by hand. It had an "encoding" attribute of "system" and was saved as an ANSI filetype, and I really wanted UTF-8. I opened the file in Notepad++ (my preferred text editor - http://notepad-plus-plus.org/) and changed the very first line to this:
<?xml version="1.0" encoding="utf-8"?>

I then used Notepad++ to change the file encoding to UTF-8 using the Encoding Menu -> "Convert to UTF-8" command.


I then knocked up a quick XSLT file to show the basic information - if you've any coding/html/xml knowledge it should be fairly obvious how to edit it. It would benefit from some classes and a suitable CSS file for presentation.

I've added the wheat beer I'm planning for the weekend using this method:
http://www.fairwater-brewery.co.uk/2012/02/weiss-weiss-baby/

There must be a simpler way of doing it, but this will do me until I find one..!

Cheers,
Bryan.
 

Latest posts

Back
Top