I am currently working on a project where it was necessary to conditionally inject some content into certain properties on some pages. Dynamic Content didn't really help me because what I wanted to do was replace entire properties with content from a property on another page and do it in a nice way for the editor. Linking the page with a shortcut to another page didn't help me because it needed to be only a partial replace and also conditional.

Here's an example - and I know there are better ways to do this but I want an example that won't compromise the Intellectual Property of what I am actually doing :)

Lets say you have a news article at http://myepisite/News/SomeArticle. The article has a nice big image on it and you want to be able to swap the image out with a different one (lets forget the fact that you'd probably just do this with two properties). You have a sub-page storing the smaller image in a property at http://myepisite/News/SomeArticle/LowImagery, which is hidden from the site. The way that you trigger the load of the low image is by URL QueryString, e.g. http://myepisite/News/SomeArticle?bandwidth=lo. (If you want some more tips on achieving this URL neatly, see my posts or other posts on URL rewriting.) Anyway, you could write a custom property type etc. to do this, but that's a fair whack of work and you'll need to create a new custom property for every content type that you might want to replace.

So how do I achieve this in a neat, generic way? EPiServer provides a nice way, but it's not the most well documented route and neither do they really recommend it. Still, I think it can work well if properly implemented. The way I implemented to achieve this was using a custom Property Get Handler.

When EPiServer asks for a page, it builds a PropertyDataCollection of all the properties on that page, along with their values. This PropertyDataCollection contains all the user-defined properties along with some that EPiServer add in as well such as PageLink, PageLanguageBranch and others. These are absolute lifesavers, although they are not well documented. The PropertyDataCollection has a default indexer which, when called, calls to a helper method to get the actual PropertyData for a property. The default helper method is a static method called 'DefaultPropertyHandler' on EPiServer.Core.PropertyGetHandler. This helper method looks for the the actual property data in four stages:

  1. It looks at the property on the current page and the current language
  2. If that is empty, it checks to see whether the property is language specific and, if it is, whether the current language is the master language. If not, then it grabs the master language page and returns the value from that property.
  3. If language isn't an issue, then it tries to get the property value from the linked page, if any.
  4. If there is not data on a linked page, then it tries to return a dynamic property value with that property name.

This works well and is the default that probably fits 99% of EPiServer installations. However, EPiServer kindly allow us to replace this default Property Get Handler. All you need to do is write your own method that matches the delegate for the handler, and then set an EPiServer property like so:

EPiServer.Core.PropertyDataCollection.GetHandler = new GetPropertyDelegate(Test.BandwidthPropertyGetHandler.BandwidthPropertyHandler);

I'm sure you can set this in most places where you need it, but I just put it into the Application_Start of Global.asax.cs. So we can see how easy it is to override the property handling, but what does our custom method actually look like? The following code is incomplete, untested and partially commented out, but it should give the idea. The two parameters coming in are the property name being queried for data and the property data collection for the current page/language. Notice that rather than use the default indexer for properties, when asking for a property data value I am explicitly calling the 'Get' method - this prevents nasty infinite loops where my custom handler keeps calling itself.

namespace Test
{
    public static class BandwidthPropertyGetHandler
    {
        // Methods
        public static PropertyData BandwidthPropertyHandler(string name, 
PropertyDataCollection properties) { // check querystring to see if we need to replace property (where possible) HttpRequest Request = System.Web.HttpContext.Current.Request; if (Request.QueryString["bandwidth"] == "lo") { // we need to swap low bandwidth if it's the right property name // you could drive this any way you like - don't hardcode it in production :) if (name == "ArticleImage") { // lets reach out and grab the data from the sub-page PageReference ThisPageReference = (PageReference)properties.
Get("PageLink").Value; PageDataCollection ChildPages = EPiServer.DataFactory.Instance.
GetChildren(ThisPageReference, LanguageSelector.MasterLanguage()); foreach (PageData ChildPage in ChildPages) { // find an article subpage if (ChildPage.PageTypeName.ToLower() == "article subpage") { // grab our property and return it return ChildPage.Property.Get("ArticleImageLow"); } } } } // just return the default handler return PropertyGetHandler.DefaultPropertyHandler(name, properties); } } }

In my actual implementation I handle languages properly, error handling, null property values and all sorts of other things, but it should be fairly obvious how that would work. In essence, this is a very simple way of customising properties to make them do fairly clever things without customising property types themselves. In fact, this would be a nice way to retro-fit a feature such as bandwidth tailoring or other targeted content to an existing type. Just remember that if it's not a special case you should be handling, call the default handler to do it's stuff with that property! Also, it might be best to try to keep your injected property types the same as the property type on the owner page. Not sure what would happen if you messed with that.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist

I needed to throw together a quick geolocalisation demo for EPiServer v5 R2 the other day and to do that it was necessary to override some of the default URL rewriting behaviour of EPiServer. I knew it could be done, but I'd never actually had to write a custom URL provider before, so Ted Nyberg's blog post on rewriting in EPiServer gave me a good kick-start.

My geolocalisation changes worked a treat (maybe I'll blog about that another time) but I did come across one really nasty 'feature' in EPiServer. I did find a workaround though, so I'll share it with you. Some background first though.

As you may know, EPiServer has the nice ability to add a file extension on to pages. Before you rush off and try this out on your live site, be aware that it does change the default behaviour a little, for example it stops trailing slashes from working on the URL, e.g. this works:

http://myepisite/SomePage/

...but this does not...

http://myepisite/SomePage.htm/

In fact, I like this feature because when using an external cache provider (such as Akamai), page extensions are A Good Thing as it knows how to treat them, and it also reduces the number of a URL 'possibilities' for a single page, so reducing the cache usage. As a bonus, it can also help with security as it slightly abstracts the page engine from the URL. Why not use the extension 'cfm' and then watch and laugh as all the ColdFusion-specific attacks roll in :)

So I set an extension on my geolocalisation demo of '.htm' (done in the urlRewriteExtension property of the site settings element in Web.Config, make sure you put the dot in the extension as well otherwise you'll get SomePagehtm). So far, so good, and the out-the-box demo templates site appeared to run fine. But then I noticed a weird quirk. On the menu across the top, the various links made sense, for the most part:

News -> http://myepisite/en/News.htm

Events -> http://myepisite/en/Events.htm

and so on... but the Start link was all messed up:

Start -> http://myepisite/en.htm

What was strangest of all though was that this link actually worked! This made no sense on any level, and it was obvious that some internal fudge in the default URL rewriter was catching this as a special case. This was confirmed when I found this post from EPiServer support. They'd obviously found this 404'ing so built a special case for it.

So why do I care? Because this breaks the URL model and breaks my geolocalisation scheme quite badly. That link should 404 or else I have an issue. Ideally, I want to actually write out the proper link. So I started digging. It turns out that you get a link like this when you have an EPiServer Start Page and ask for the LinkURL for it. The default URL rewriter seems to munge it up and spit out this crazy short URL rather than a nicely formatted link. This is the same for any language, for example the Swedish start page gives sv.htm. Ideally though, I would want it to write out something like this (the page is actually called Public in the English version):

http://myepisite/en/Public.htm

I mean OK, it looks like any other page rather than a start page but surely that's better than en.htm! So... how do we go about getting the right page link rendered out and bypassing EPiServer's little 'fix'? Well, we can do it with the URL rewriter. I'll let Ted's post explain how to actually create the URL rewrite provider, but once you have the rewrite provider ready, you can override the ConvertToExternalInternal method as follows:

protected override bool ConvertToExternalInternal(UrlBuilder url, object internalObject, Encoding toEncoding)
{
    // apply default rewriting first
    bool bRewriteSuccess = base.ConvertToExternalInternal(url, internalObject, toEncoding);

    if (bRewriteSuccess)
    {
        string[] urlSplit = url.Path.Split('/');
        
        if (urlSplit.Length == 2)
        {
            // default page

            string DestinationCountryCode = urlSplit[1].Substring(0, 2);

            EPiServer.Core.PageData StartPage;

            try
            {
                StartPage = EPiServer.DataFactory.Instance.GetPage(
new EPiServer.Core.PageReference(EPiServer.Configuration.Settings.Instance.PageStartId),
new LanguageSelector(DestinationCountryCode)); } catch { // no page with that language, just grab the link anyway and it will
still work just with the current language name
StartPage = EPiServer.DataFactory.Instance.GetPage(
new EPiServer.Core.PageReference(EPiServer.Configuration.Settings.Instance.PageStartId)); } url.Path = "/" + DestinationCountryCode + "/" + StartPage.URLSegment +
EPiServer.Configuration.Settings.Instance.UrlRewriteExtension; } } return bRewriteSuccess; }
This is not a fully-tested solution and it might need more work, but it shows that it is possible to fix this troublesome default behaviour. My geolocalisation demo then wrote out links as I would expect, and seemed to work perfectly across languages too. Hope this is of some use to anyone with similar issues even if it only gets you started on a fix!

Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist

EPiServer Norway are associated with an EPiServer community project called EPiCode which had its annual awards on the 12th of November as part of the Christmas Tech Forum. I was really pleased to see the Module of the Year award went to my pals over at NetworkedPlanet for their EasySearch module. Unlike some of the other modules on EPiCode, it isn't free to use commercially - but it is free to download and try out and fills a nice gap in the EPiServer search space.

A bunch of other 'active contributors' were lucky enough to get an iPod Shuffle in the awards - including me for contributing CloudCuckoo and HyperThumbnail on behalf of Interakting. Thank you EPiServer Norway!

You can read more here.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist

Introduction

Interakting use both Open Source and proprietary products to deliver solutions for many companies. We always try to select the best tool for the job, and when it comes to Content Management it is no different. We have a range of tools we consider using including various Open Source tools (e.g. Nuxeo, DotNetNuke) and also our proprietary offerings (EPiServer, ADXSTUDIO). In the context of many projects it would certainly be possible to deliver a ‘successful’ project in either a proprietary or an Open Source solution. However, when we consider budgetary, functionality, deadline, support and longevity constraints, all of these areas are problematic in the Open Source arena, whereas proprietary systems such as EPiServer can provide an arguably better and more cost-effective solution. This article discusses some of the reasons for this. The majority of 'pure CMS' sites we deliver are on the EPiServer platform and so this will form the basis of our discussion. Interakting is an EPiServer Solution Partner.

Budgetary

With a proprietary CMS such as EPiServer, the main costs are ‘up front’. The client would be buying a licence to use EPiServer CMS, and the cost of this covers the effort and time taken by the vendor to develop and support the product. This means that the vendor does not need to find other ways to recoup their costs beyond the licence fee and an optional small annual support fee. The client can therefore budget for the outright licence as a clearly transparent and defined cost.

Open Source costs are far less clear, as companies who ‘own’ an Open Source initiative may give the software away ‘free’ but then seek to recoup their costs, even if only running costs. This is usually done by support contracts, consulting or selling additional ‘modules’. It is easy to be trapped into a ‘free’ product and then find that the actual cost is far higher.

Functionality

As proprietary systems are designed to be sold as widely as possible to reach the maximum number of customers, functionality in proprietary systems is usually excellent and if additional functionality would assist their sales then the company owning the product will often update their core product or provide value-add modules at low or no cost. This is very much the case with EPiServer, who have grown rapidly due to their responsiveness to customer demands and now have many thousands of seats worldwide. The CMS is particularly user-friendly and intutitive and can be used by novice users without the need for costly training.

In the Open Source arena this becomes more complex. The popular view is that the community ‘works together’ to build a product for the good of the community. This works well, to a point, but ultimately people are not entirely altruistic. Sooner or later (and sometimes always) they only contribute to things that benefit themselves. This means that the ‘out of the box’ product is often minimal functionality, and even if it is fairly well featured then those features are often not very flexible and designed for the use of the company that commissioned them with specific needs. It is unlikely the community will help add or update functionality and therefore it is left to the project team to do so, which can be fairly hard and time consuming. User training is likely to be required, particularly post deplyoment when users change jobs and new users need to work with the CMS.

Deadline

As a general rule, any proprietary systems must be designed to provide a very rapid solution as this is a key selling point since the market is very competitive and unforgiving. In this regard EPiServer stands up very well which is one of the many reasons that Interakting has selected this tool. The well-featured out of the box nature of EPiServer, together with the well-documented and supported APIs, mean that a robust solution can be built rapidly and efficiently. The tools are built with the clients business needs clearly in mind as much as the developers.

In an Open Source project, it has generally built by developers with a very code-centric approach. There is an expectation that the basic product will be customised by developers as needed, and the out-of-the-box functionality capability is usually minimal. Even with ‘starter’ kits for a particular tool, there is often a large amount of code and customisation to be done. Agencies promoting open source solutions capitalise on this aspect as it is very lucrative to develop the added functionality needed for more complex reqirements such as multi-lingual non-Latin support

Support

With EPiserver, as part of the licence agreement, the vendor undertakes to provide support and their reputation relies on this support being accessible and effective. The support is also usually rapid and efficient to respond with managed Help Desks staffed by knowledgeble individuals. They are able to respond with authority on support issues as they designed, wrote, maintain and own the codebase.

For an Open Source tool, the support is either an expensive add-on from the company providing the tool or is community based. If a company is supporting a tool this is often not so much of a problem, although there is an issue that they are supporting code that they quite possibly did not write. From our experience (remember that we also work with Open Source solutions when we feel it appropriate), support from the community is often slow and inadequate for projects that have a critical path.

Longevity

EPiServer is committed to the products they sell and even if they discontinue a product will generally provide migration or upgrade paths. Generally speaking, it will also be clear in advance whether a product will be passing out of support and therefore a proper exit or migration strategy can be planned well in advance. EPiServer is also helpful in that, in the event of it ceasing to trade, it has made its code available to its licensees through an escrow arrangement at a nominal annual cost (although this is optional).

Open Source projects are often left unfinished or unsupported once the community using them has moved onto something different. As a general rule, Open Source projects have a limited time in which they are actively updated and maintained and once a critical inactivity threshold is reached then they effectively become ‘legacy’, are taken into closed source or amalgamated into something larger. It can also be harder to plan an exit strategy as the ‘lifetime’ of a product is usually unclear.

Summary

In summary, we believe that for the many projects, the unknowns and variables involved in taking the Open Source route will result in a slightly higher initial cost of development and deployment and a significantly higher cost of ownership over a two year period following the initial go-live.

By choosing to use a well-proven CMS which uses the .NET framework, a project is grounded on a solid, well defined and tightly costed product and the real cost of deployment and support over a 2-5 year lifetime can be estimated with a far higher degree of accuracy. Ongoing maintenance, functional enhancements and support will also be easier to define and budget. Finally, a large pool of .NET developers able to work with EPiServer and are readily available at competitive day rates meaning the client has total flexibility and would not be locked into any single supplier in the future.

If you're looking for a CMS solution for your web site, shouldn't we be talking?


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist

Last night I was at a BCS Young Professionals Group meeting at the BCS offices in Southampton Street, London. The meeting was part of a 'SkillCentre' series being run with the help of a consultant called Anthony Rees facilitating, and the subject last night was 'Negotiation Skills'.

The session itself was excellent, culminating in groups coming up with a simple mnemonic to remember some basic concepts for negotiating. The group I was in came up with the mnemonic 'winwin':

What do you want

Investigate feasibility

Note it down

Walk in their shoes

Identify tactics

Negotiate!

Another group came up with the 'winning' mnemonic of 'KPMG', which raised a chuckle. I'm not sure I can remember it exactly, but it went something like:

Know

Prepare

Maximum (& minimum)

Goals

Personally, I found it memorable but less useful. But that's probably just me being biased. Following the main session there was a chance to network over wine and nibbles which was just as valuable as the session itself. And kudos to the BCS for putting on a nice Chilean Merlot :)


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist

My XP laptop had ground to a halt - 6 months without a rebuild and it had got so clogged that it literally took 5 minutes just to boot. I needed to wipe it and start again but the head of our technical team offered me a fresh laptop with a clean Vista Business build. Deciding that being a guinea pig was a nice idea, I accepted it. The 4 gig of ram (up from 2 gig) was the sweetener that made up my mind for sure :)

As I was setting it up just how I wanted it, one of the things I needed to do was sync my two mobile phones with it. I have both an HTC 4350 (Herald) from work and my own personal HTC TyTN II. On my XP laptop I used ActiveSync to sync up my calendar, tasks and contacts.

Knowing that ActiveSync has been replaced on Vista, I was hoping for an easy experience. After plugging in my TyTN II, Vista offered to sync my media files. Fine, but I wanted to sync with Outlook so I cancelled the dialog and started my hunt. In Control Panel I found 'Sync Centre' which offered to sync my media files again. This was getting annoying. Contacts and/or Outlook were mentioned nowhere.

Maybe the 'Windows Mobile Device Centre' in Control Panel was my best bet? Nope. That just had settings on whether I wanted to connect via USB and Bluetooth or not. Nothing about syncing. Googling didn't help me that much. There doesn't seem to be much info about this. Is it that obvious? Am I missing something?

Actually, I was missing something. The latest download of Windows Mobile Device Centre (currently 6.1 as I write). This is basically what ActiveSync used to be, and syncs up all the bits and pieces you'd expect with Outlook. In fact, it's very smart and clean and appears to be a nice improvement on ActiveSync.

I thought it worth blogging this for two reasons. Firstly, hopefully this will get indexed so that it can be a quick help to others who were in the same boat as me. Secondly, is this part of the problem with Vista? It's not exactly intuitive that you have to install an updated version of a Control Panel applet to be able to sync (although behind the scenes it's more than that, of course). It almost seems that the out-the-box install is half baked. And the help isn't much help.

It's possible that I still missed a trick, of course, and if I have done then please feel free to comment here and set me straight!


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist

Chrome threw the following error when posting to a forum:

image

(my login name and domain is deliberately blanked)

This warning 'Exploit-ObscuredHtml' isn't thrown when doing exactly the same in Internet Explorer, so I'd be interested to know why it's throwing the virus alert. Possibly because it's running the javascript in a separate process to the HTML? Unlikely. More inclined to think it's because it's in the unsecure 'Documents and Settings' folder whereas IE uses the rather more locked-down Temporary Internet Files folder.

Either way, I can imagine lots of sites would use Javascript that would trigger this and I'd imagine other AV tools would flag it too. Surely the AV vendors and/or Google need to address this somehow? Isn't it a bad place to put files that you will run script? If you have seen this behaviour as well then feel free to post the Url and the name of your AV tool.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist

I was listening to coverage of the Beijing Olympics on BBC Radio 5 Live this morning and it was interesting to hear what a spectator had to say about the lack of information that the Beijing organisers provide for spectators. One spectator was at the boxing and apparently there was no information about other events happening or results and, even more impressively, not even a schedule for the boxing either! I would have expected flat screens everywhere with the schedule or, at the least, a printed list.

Surely this is an opportunity for London 2012. With the vast amount of Content Management expertise across the UK, you'd think that we can put together some really great content solutions to give all the right information in the right places to the right people. Just imagine - TV coverage mixed with results screens and schedules... well put together, this could be the big differentiation between Beijing and London. OK, maybe we don't have flashy ceremonies, spectacular fireworks and an immersive cultural experience... but at least we love all sports and we can give a 'sports rich' environment for spectators.

Beijing is out to impress the world, but seems to have missed a trick by not giving spectators the information they need. Let's get this right in London.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist

I recently needed to get the NT user name from VBA code. Not a problem, Microsoft have an advisory note that tells you how to do that and there's a good summary of it on this post:

http://blogs.officezealot.com/charles/archive/2004/12/10/3574.aspx

However, there is a ptentially serious security problem with the other method that Charles suggests on that post - using the environment variable like this:

Environ("USERNAME")

If you are using the username check in VBA for security purposes (for example, matching a username against a list of known users permitted or restricted on some actions) then the method above does not guarantee that the actual username of the logged on user will be returned.

The user can override the default username setting by adding a new environment variable (Control Panel -> System -> Environment Variables) called USERNAME and setting it to whatever they want. Effectively, they are taking the identity of another user as far as the variable is concerned, and anything that looks it up.

It is therefore safer from a security perspective to use the Win32 API call. Note that if you are doing security in VBA you have a bit of a problem anyway though because even if you password protect you code, it's easily crackable.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist

On our blogs, we recently found we were getting this error when trying to edit some posts:

image

The id's given were occasionally different but it was always the same format...

"Could not find category id XX in the Checkbox list which has XX items."

Somehow it seems that SubText has got itself in a twist and allocated invalid category id's to the posts. I suspect that this is actually caused by a funny bug between SubText and Microsoft Live Writer. You see, when you write an article in Live Writer you can allocate the categories for it and post it up to SubText. So far, so good. However, the bug occurs when you have a Post Category and an Article Category with the same name. When the Web Service request hits SubText it might not pull out the correct category id - probably because it checks only by name and grabs the first one. The problem we were having is that some posts were getting added with a category id for an article. Changing the category name for the articles fixed the problem.

You can see if any of your posts have this problem by running the following SQL against the SubText database.

   1: select * from subtext_Content, subtext_Links, subtext_LinkCategories
   2: where subtext_Content.ID = subtext_Links.PostID
   3: and subtext_Links.CategoryID = subtext_LinkCategories.CategoryID
   4: and PostType != CategoryType

If you get rows back, then you need to tweak your data :)

Once you've fixed your data, then the main recommendation I'd make is to use different category names for posts and articles. That way, Live Writer or other Web Service based blog tools won't confuse SubText.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist