Home > Blog > 2011

All Posts From : 2011

The Umbraco Community

Last week I was lucky enough to attend the excellent Umbraco yearly developer festival, CodeGarden. For three days I got to hang out with a few hundred other Umbraco developers from all over the world, talk shop, get a glimpse of the upcoming awesomeness in V5, pick up some cool tips and tricks, and above all, have FUN.

Umbraco makes a big deal of the fact that they have a friendly and helpful community. They're very proud of it in fact. And rightly so. The Umbraco community is hands down one of the most fun, generous, and helpful group of devs that I interact with on a regular basis. I work with a lot of other open source frameworks and tools, as well as a good number of commercial ones, and of all of them, getting help from the Umbraco guys is the most fun. There's no elitism, everyone's happy to offer advice, and above all, everyone is happy to share their stuff. If someone comes up with something cool, the chances are that they'll release it for others to use.

The community is also very laid back. I've not seen any unpleasant exchanges on the forums, and everyone always has a laugh when they get together for the user group meet ups and the bigger country wide get togethers.

I think the Umbraco guys have managed to achieve something really special. not only have they managed to build a pretty damned cool CMS framework, but they've managed to attract, and promote a great community of passionate, talented and helpful people as well.

I genuinely look forward to meeting up with the guys when we get together, and its always a blast. How many other dev communities do you know who can settle an argument about technologies with a 60 man pillow fight? Or who's members would set up a charitable foundation to help poorer devs get to the annual festival?

:)

Media Copy Package For Umbraco

I've released a new package that allows you to copy media library items! You can download it from the our.umbraco site, here!

Custom Menus Updated to Version 1.1

I've updated my Custom Menus package to include two new features!

The first is the ability to have members of the Administrator group see the normal menus instead of the ones you've set up in the rules. To enable this, set the new ignoreForAdmin node in the customMenus.config file to true. Once enabled, it will disable all custom menu sets that you've set up in the config file, as long as the logged in user is a member of the Administrator group.

The second update allows you to make the rules affect the Media section as well. To switch this feature on, simply set the new useInMediaSection node in the customMenus.config file to true. This will make the package check the rules against media items as well as content ones. Everything else is exactly the same. As with content nodes, the package will respect any permissions that are already defined on the media items, so if a user cannot perform an action and you assign it to the node, they still won't be able to perform that action.

Here is an example of a config file using the new config items:

<?xml version="1.0" encoding="utf-8" ?>
<customMenus>
    <ignoreForAdmin>true</ignoreForAdmin>
    <useInMediaSection>false</useInMediaSection>
    <menuRules>
        <add docTypeAlias="settings" nodeId="" clickAction="javascript:UmbClientMgr.appActions().openDashboard('content');" menuItems="refreshNode" />
        <add docTypeAlias="settingsHomepageBoxes" nodeId="" clickAction="javascript:UmbClientMgr.appActions().openDashboard('content');" menuItems="create,sort,separator,refreshNode" />
        <add docTypeAlias="settingsHomepageBox" nodeId="" clickAction="" menuItems="delete,separator,publish" />
    </menuRules>
</customMenus>​

To upgrade from a previous version, all you need to do is replace the DLL in your bin folder with the new one, and update your config file to include the two new settings.

You can download the updated version of the package here.



Using the Twitter for Umbraco Package with the Feedcache Package in Umbraco

I often use Warren's rather excellent Twitter for Umbraco package to display Twitter feeds on websites. To save on hits to the Twitter server (especially on busier sites) I cache the macro, often for about 20 minutes (unless the feed is updated on a more regular basis). This has always worked fine, until recently, when I had an issue on a client site where the feed kept showing up empty.

I'd not come accross this before, so I did some digging and found out that the Twiiter for Umbraco package was getting a 403 error, and therefore no Tweets, and the Macro was caching as empty. After some digging around, I found out that Twitter have started limiting access to the open feeds, to roughly 60 or so requests an hour (this is called Rate Limiting, you can read about it here). This was still a bit odd, as the site should only have been hitting the feed three times an hour. Then I discovered that they had some other apps hitting the feed as well, that was causing us to hit the limit.

The Twitter for Umbraco feed doesn't cache the response from Twitter, so if it can't get a list of Tweets because you've fallen foul of Rate Limiting (as we had), or if the Twitter feed is unavailable (which also happens more than I realised), then you're stuck with no Tweets.

I looked into a solution for this, and came up with the idea of using Darren Ferguson's Feed Cache package to download and cache the feed (as that way if the feed was unavailable we'd still have a cached copy to read). It turned out to be quite simple, with only a few tweaks needed, so I thought I'd cover it here for anyone who's interested!

First, make sure you have the Twitter for Umbraco package installed, and make sure that you have the Macro up and running on a page and that it's pulling out Tweets and displaying them. Full instructons for setting up the feed are on the Twitter for Umbraco project page.

Next, install the Feed Cache package, again, the setup instructions are included on the project page.

Once both are installed, you can get everything set up. First up, you need the URL that your Twitter Macro is using to get the Tweets. This is pretty easy to get. Go into the developer section in the back office, and open the XSLT file called "cws_twitterStatus.xslt". Scroll down to the beginning of the "match" part of the template, and you'll see a variable called "twitterXMLUrl". Use an XSL value of just underneath this variable to get the feed (don't forget to get rid of this once you've got the feed URL!).

<xsl:value-of select="$twitterXMLUrl" />

Armed with the feed URL, you can now open the config file for the feedCache package, which is called "feedcache2.config" and is located in the "config" folder of the site. Below is an example of the file, with a feed set up:

<?xml version="1.0" encoding="utf-8"?>
<Configuration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <CachePath>C:\inetpub\wwwroot\mysite\App_Data\FeedCache</CachePath>
  <Feeds>
    <Feed>
      <Url>[PLACE YOUR TWITTER URL HERE]</Url>
      <LocalFile>mytwitter.xml</LocalFile>
    </Feed>
  </Feeds>
</Configuration>

Notice that we set a path to the feed to save its XML to (make sure that App Pool identity can read, write and modify to the location you specify, I normally use the "App_Data" folder). We also set a file name for the twitter feed.

Now all we need to do is schedule the feed to run on a regular basis. Open your "umbracoSettings.config" file from the config folder of the website, and scroll down to the scheduled tasks section. You can then add a scheduled task to the section for the feed cache. The interval is in seconds, the example task below will check the feed every 15 minutes. Here is an example of the task:

<scheduledTasks>
    <task log="true" alias="feedcache2" interval="1800" url="http://[ENTER YOUR URL HERE]/umbraco/plugins/FergusonMoriyama/FeedCache2/FmFeedCache.aspx" />
</scheduledTasks>

You can run the link from the task in a brower to make sure that it's working. If it did, there should be an XML file with the name you specified in the folder you specified. If there isn't, the main things to check are that your Twitter URL is correct, and that the permissions are set properly on the path you specified for the feed to save to!

Once that's done, you just need to make a small change to the "cws_twitterStatus.xslt" file in the developer section. First go back to the section that sets the Twitter URL and comment it out. Replace it with the folowing code:

<xsl:variable    name="twitterXMLUrl"    select="[RELATIVE PATH TO XML FILE HERE, e.g. '../App_Data/FeedCache/mytwitter.xml']"/>

Make sure that you set the path to the file that the feed is saving to correctly! Once that's done, scroll slightly further down the page, and you'll see two for-each loops that actually display the Tweets. They're currently using an umbraco.library call, we need to change that slightly. Change the first for-each to:

<xsl:for-each select="document($twitterXMLUrl)//statuses/status">

and the second for-each loop to:

<xsl:for-each select="document($twitterXMLUrl)//statuses/status [in_reply_to_screen_name = '']">

Save the macro, and you're done! You now have a Twitter feed that's cached, so if the feed is unreachable, your site will still display the tweets!

Upcoming Umbraco Articles

One of the reasons that I started this blog was so that I could post about some of the things I've worked on, but also to share how I've done some stuff. I've had a few requests for more information on some Umbraco related topics recently, so I'll be posting them up over the coming week or so. In case you're interested, the posts will cover: