Wednesday, August 30, 2006

Atlas properties, how do I do that?

Not long ago I was asked by EPiServer to write an article for the EPiServer TechNews email newsletter. I gladly accepted the opportunity and started racking my brains for a good topic to write about.

I finally decided on a topic, "Advanced property development with Atlas" and have submitted the article for the next version of TechNews. In short the article is about the different ways to create advanced properties, and introduces the use of Atlas, an AJAX library. I have created some sample properties that will be available for download (with the source code of course), when the newsletter comes out next week.

Watch this space for more, or your email inbox if you're subscribed.

Tuesday, August 29, 2006

Windows Live Writer integration

Last night I was chatting online with a colleague of mine, JD, and he pointed me in the direction of this blog post from Mikael Runhem (may need to scroll down the page to find the post I'm referring to). It was quite weird timing actually as we were discussing the possibility of creating this ourselves. Looks like we got beaten to it!

The cool thing about this post is that it has apparently been posted directly from Windows Live Writer (WLW), directly to the EPiServer blog template. Michael writes:

Not to my surprise, Ruwen has made an excellent job, creating a " blog server emulator" that makes EPiServer pretend it is a Metablog compliant blog server! With this approach we can not only support the new upcoming blog program from Microsoft, Microsoft Live Writer, but also other Metablog compliant blog programs. This opens up for people using Macs, Linux, cell phones etc to create content in EPiServer!

If anyone is interested in WLW, I have been working on a plug-in that integrates the online file storage site Box.net. I have the plug-in ready for initial beta testing and am trying to get a project space on CodePlex to store it. If your interested in this plug-in then read more about it here.

Thursday, August 24, 2006

FUrlX updated

Just a quick post to say there is a new version of the EPiServer Research module FUrlX (A module that updates the Friendly Url function to remove the JavaScript reliance). This update fixes a problem regarding the querystring being lost on page postback.

The updated version can be downloaded from the FUrlX project page.

Tuesday, August 22, 2006

Advanced delete with link cleanup

A common question I get asked when demonstrating EPiServer to potential clients is:

How does EPiServer handle links when deleting a page? Does EPiServer clean up potential broken links?

With the standard EPiServer delete function there is no link cleanup, which means you can easily end up with broken links. Now this is something that I thought would be easy in EPiServer, as the standard function even tells you what the linked pages are when you try to delete. So, why is there no ability to clean up the links before delete? Answer, I don't know, but maybe it will be coming in a future version :)

The standard delete function
[The standard delete function]

Well I want it now! So this is the driver behind my want to create an advanced delete function, that gives the user the ability to clean up links before a page is deleted.

I have started work on a prototype, and it's working quite well so far. My delete page plugs into EPiServer using the "alternate files" function (a function that allows you to implement your own version of an admin or edit mode function). This means my advanced delete overrides the standard delete and is available through the standard menus.

If a link to the selected page is detected, then some options are supplied to either remove the links or replace the links. And for the web admins out there, I have added an option so you can force the user to clean up all links, before the page can be deleted (you know you want the power).

Here are a couple of screenshots from my current prototype:

Standard delete menus
[The standard delete menu activating the advanced delete function]
My new advanced delete function
[The advanced delete function with force link cleanup enabled]

It works okay at the moment but there are a few things I'd like to improve on, such as
  1. Better detection of linked pages (works well at the moment but a little problem with caching in EPiServer maybe?).
  2. Add override function for site Administrators.
  3. Better access denied handling for when users try to cleanup links on a page they don't have access to.
Anyway, I have added the prototype to EPiCode so if your not already registered, then go register now and download a copy today! Also, if you think of other things that could improve it, then add a comment or add a ticket in EPiCode.

Friday, August 18, 2006

Tell me when my scheduled jobs fail - Part II

Not long ago I posted about writing an EPiServer scheduled job that notifies me when scheduled jobs fail. I created a prototype, which works well, but is flawed in that if all scheduled jobs are failing (including my notifier), then I won't know about it. So as a result I started thinking of other ways this could be done.

In my thinking I came up with two other possibilities. The first thought is to use log4Net, and the other is to create a Windows Service.

Using log4Net
Using log4Net is probably the best solution for this sort of thing as it's already part of all EPiServer sites, and to setup notification of errors is just a configuration task. By implementing an SmtpAppender and a logger on the EPiServer.DataAbstraction.ScheduledJob namespace, you can quickly and easily setup email notifications about scheduled job failures.

Here's a sample section from the config file that I got working in my sample site:

<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="errors@domain.com"/>
<from value="errors@domain.com"/>
<subject value="Error encountered in EPiServer461 scheduled job" />
<smtpHost value="127.0.0.1" />
<bufferSize value="512" />
<lossy value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d\t%X{siteid}\t%m%n" />
</layout>
</appender>

<logger name="EPiServer.DataAbstraction.ScheduledJob">
<level value="ERROR" />
<appender-ref ref="SmtpAppender" />
</logger>


Using a Windows Service
With a Windows Service I could either hook directly into the EPiServer database and query the job history, but the better thing to do would be to create a web service in the website. The web service could use the EPiServer API the same as the scheduled job and return a dataset of failed jobs (or something like that).

The advantage of using a Windows Service is that the one service could be configured to interrogate multiple EPiServer sites and provide a summary email for all the sites.

This option would obviously require a lot more work as a Windows Service and Web service would need to be created. However, with this approach you could get a lot more flexibility and could customise the email to be a bit friendlier, and with more information.

EPiServer Scheduled Job
If you are interested in the scheduled job prototype that I created, then you can download it from here. It is pretty simple and all I was going to add was some filtering based on when the job last ran. This is so you wont get repeating notifications.

Monday, August 14, 2006

Multipage selection property

Have you ever wanted to store multiple page references in one property in EPiServer? I know I have many a time, but EPiServer doesn't provide you with a property to do this, so I ended up creating one myself.

Nick Urry and I have created a new property that pops up a new window that allows the user to select multiple EPiServer pages. The selected pages are stored in a single LongString property in XML format.

The XML format used is similar to a hyperlink HTML tag as using this format gives you a few things for free. One is that you can take the XML and render it into some HTML with little change required and the output would be a list of hyperlinks. The other advantage is that when doing an export or mirroring, the EPiServer code is designed to map these types of links in your properties to the new pages in the destination site! Trying to do this yourself would bring on a massive headache.

Heres an example of the content of the saved property:
<links>
<a href="/templates/Page.aspx?id=16">Tips and Trix</a>
<a href="/templates/news.aspx?id=92">News</a>
<a href="/templates/Page.aspx?id=6">Friendly URL!</a>
<a href="/templates/Page.aspx?id=4">About EPiServer 4.60</a>
</links>


The UI is designed so it shows you the number of selected pages in the property. You then click the expand button to edit the content. The dialogue that pops up displays the names of the selected pages with options to re-sort, delete and add new pages (I plan to add some better sorting to the dialog soon that does more than move up and move down).

So here are some screenshots of the property in its current state. The first one is showing the property in edit mode, the second is showing the popup that allows editing of the selected pages.

Multipage property displayed in edit mode

Multipage property editing dialog

So now you may be asking, can I have a copy, and where can I get it?

Well, this property has just been added to the EPiCode project so if you haven't already signed up, then sign up today and download the source.

Wednesday, August 09, 2006

EPiServer friendlier URLs

A new function that was introduced in EPiServer 4.60 was the Friendly URL function which allowed you to use path type URLs for your site. This was great news as it is a commonly requested feature from most of our clients, especially the government ones.

One major issue with EPiServers implementation was that it required JavaScript enabled - bummer! This is a problem for me as all NZ e-government compliant sites need to degrade gracefully when JavaScript is disabled. What this means is without JavaScript enabled, templates would no longer post-back, and basically all functionality would stop working :(

So I was excited to hear that the EPiServer research guys have created an update to the function called FUrlX, which removes the JavaScript reliance, great!

From my testing thus far I have found it works as expected, displaying the URLs in the path format, and with JavaScript disabled my post-backs still work. The great thing about it is that it uses all the current settings of the standard function and can be plugged in with minimal configuration and no need to recompile.

If your interested in this I suggest you check it out at the research site.

Tuesday, August 08, 2006

Tell me when my scheduled jobs fail please

Just recently I discovered a problem with an EPiServer scheduled job that I built for a client that kicks off a search engine re-index on a nightly basis. What I didn't realise was that the way in which I was starting the re-index was completly stuffed and the as a result the job had been failing for about a month.

This got me thinking about ways to notify someone when a scheduled job fails. Now I'm not just thinking about notifing for my custom created jobs as that would be easy, instead what I thought would be good is a process that notifies me about all the EPiServer job failures (standard and custom ones).

I can think of two ways to get this information, one is directly from the EPiServer database tables where it stores the history of the scheduled jobs, the other is to use the EPiServer API to get the status of scheduled jobs and their history. Now I always prefer to use the API as much as possible when doing product development so I'm going discount the direct database access for now ;)

Some other things I want is to be able to schedule when I got notifications about failed jobs and have the notifications summarised in a single email.

So as a result I have started creating another EPiServer scheduled job that notifies me about scheduled job failures. The idea is that when it runs it will trawl through all the other scheduled job status' and history, pick out any failures and email them to me.

I'll update this when I have something working but if you have any other ideas please add a comment below.

EPiCode - Check it out now

One of the things I am looking to do with this blog is to put a few handy tips, tricks and code samples from my day to day experiences with EPiServer.

A great place to start if you are interested in EPiServer would of course be the EPiServer site itself and developer forums. I have found the site and forums very useful over the past year. However another great resource that I recently came across is an open-source project called EPiCode setup by a guy called Steve Celius.

The EPiCode project requires you to apply for membership but once you are a member there are some really great tools and things under development already. For example there is a base library with a few custom properties and utilties, a page type utility for advanced management of page types and properties (which is really useful), and a newletter module for sending out html/text newsletters with subscription management. This is just a sample but if you are interested in EPiServer development and want to make life easier for yourself then I highly recommend signing up and taking a look. Who knows, you may even have something great you can share with the project to :)