Tag Archives: wordpress

The Regular Jen Wordpress Theme

regularjen

The Regular Jen Wordpress Theme was inspired by the collection of Creative Commons textures created by Jennifer Dixon (aka @regularjen).

What started out as one design, ended up completely different.  I am waiting to hear back from Wordpress whether this theme will be included in the Wordpress directory.

This will be the theme web page with a link to the wordpress website for download if it is approved for listing in the directory.  Fingers crossed!

A .NET class to consume wordpress RSS

Wordpress as a CMS is not a new phenomena, and I have used wordpress as the engine for many websites and blogs, both as a complete out the box system and as a backend admin system.

So this morning I decided to make a .NET class file purely to consume wordpress RSS feeds, allowing you to use Wordpress as the back end CMS and a .NET application as the front end populated from the wrodpress rss data.

This is actually really easy to do using the RSS Toolkit available from Codeplex.  I have done this before, maybe a year ago, when building an app to consume the Seesmic RSS feed.  It worked like a dream, because you can add whatever namespaces you like to help create the class, including the yahoo media namespace which defines the RSS structure for video and images etc.

The process works like this:

Head over to Codeplex and download the RSS Toolkit binaries.  Unzip the binaries and you will find a tool called RssDl.exe located inside the folder:  RssDl\bin\Release

The RssDI.exe tool is the command line RSS compiler that creates RSS class files.  Simply open the command prompt and change directory to the location of the RSSDI.exe tool.

Then run the following command, altering the syntax according to the name of the class file you wish to make and the location of the RSS feed you wish to use as a basis for the class file:

rssdl.exe http://domain.com/path/to/your/rss.xml wordpress.vb

Let’s break the above down. It’s pretty straight forward.  You run the tool rssdl.exe, giving it the url of the rss file you wish to consume to create the class file. Finally, the name of the classfile you want to create, in this case, wordpress.vb.  You can create either c# or vb files using this method.

One thing to note, if you are using VB, I have always found this tool to be create the file with a couple of errors.  So copy and paste the created file into the AppCode folder and check for any syntax errors.  You might need to change “is” to “=” on a line that is showing an error.  I have no idea why, but that’s my experience of this tool.  Leave a comment here if you are having issues with it.

Once you have created this file and pasted into the AppCode folder in Visual Studio, you are ready to consume your feeds.  Drop a repeater, datagrid or datalist onto the page, e.g.

<p>
<asp:Repeater ID=”rptButtons” runat=”server”>
<ItemTemplate>

<asp:Label ID=”Label1″ runat=”server” Text=”" ><%# Eval(”Title”)  %></asp:Label><br />
<asp:Label ID=”Label2″ runat=”server” Text=”"><%# Eval(”Description”)  %></asp:Label><br />
<asp:Label ID=”Label6″ runat=”server” Text=”"><%# Eval(”pubDate”)%></asp:Label><br />
</ItemTemplate>
</asp:Repeater>
</p>

Add the following code to bind the RSS data to the control, replacing the url for your chosen wordpress RSS feed:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rss As RssToolkit.Rss.RssDocument = RssToolkit.Rss.RssDocument.Load(New System.Uri(”http://www.yellowpark.net/cdalby/index.php?feed=rss2&cat=7″))
rptButtons.DataSource = rss.SelectItems()
rptButtons.DataBind()
End Sub

It really is as simple as that.  So if you want to have a different feed populating a different page throughout your .NET website, you could create a new category called About Us, and use that feed to populate the About Us page in your .NET website.

More details on Wordpress RSS feeds here.

One more final point about this method of consuming RSS.  You could simply consume the RSS feed using the built in .NET tools.  I prefer this method because you get a custom class file that is designed specifically to deal with whatever the rss feed looks like that then behaves as expected and gives you full control over the look of the data in your website.