Wednesday, 3 September 2008

Edit Page - Shortcut/External link tab

Shortcut/External tab in edit mode is a useful thing. You can create different types of links there, you can also specify target frame which allows you for example to open external links in a new window. It all sounds great but do you really use it and support the target frame property in your code?

I have to admit that my code hasn't support that. Luckily for me it has changed recently but to be honest EPiServer doesn't have the best support for those properties. If you think that you will find some dedicated methods/properties to access selected values programmatically then I will save your time ... you won't!

On the other hand, all what you have to do is to get properties called 'PageShortcutType' and 'PageTargetFrame' which is not a rocket science assuming that you have a vague idea that those two properties exist.

So here is a short code snippet which I hope will save your time in future:

// get shortcut type
PropertyLinkType linkType = (PropertyLinkType) pageData.Property["PageShortcutType"];

// get terget frame
PropertyFrame targetFrame = (PropertyFrame) pageData.Property["PageTargetFrame"];

// use target frame only if we are dealing with external link
if (LinkType.External.Equals(linkType))
linkTitle.Target = targetFrame.FrameName;