Monday, October 22, 2007

How to extend the general Page functionality in EPiServer CMS 5

Still being a newbie in the EPiServer company I learn a lot of new things every day - both about the product and the company.

I've decided to share some of my discoveries here - perhaps they help other EPiServer newbies out there :-)

Today I came across quite a useful, but not-so-well-documented feature in EPiServer CMS 5: The ability to extend the general functionality of your Pages. So, if for instance you want to add a piece of code that should be executed whenever a page is shown, and which can affect that page, but don't feel like inheriting the TemplatePage type and letting all your pages inherit from your custom type, there is actually quite a neat way of doing it.

The trick is the PagePlugIn attribute. You can create a class, put the PagePlugIn attribute (from the EPiServer.PlugIn namespace) and add static method with the signature void Initialize(int) and from that method setup an event handler to handle the EPiServer.PageBase.PageSetup event.

Here's an example on how you can use this functionality to add an extra menu item to the context menu:

public class MyPagePlugin

public static void Initialize(int bitflags)
EPiServer.PageBase.PageSetup += new EPiServer.PageSetupEventHandler(PageBase_PageSetup);

static void PageBase_PageSetup(EPiServer.PageBase sender, EPiServer.PageSetupEventArgs e)
sender.ClientScript.RegisterClientScriptInclude("OnScript", "MyScript.js");
sender.PreRender += new EventHandler(sender_PreRender);

static void sender_PreRender(object sender, EventArgs e)
(sender as EPiServer.PageBase).ContextMenu.Menu.Add("MyItem", EPiServer.Security.AccessLevel.Edit, new EPiServer.RightClickMenuItem("My Script", "MyScript()", "MyScriptSubMenu"));


Monday, October 8, 2007

Off to Stockholm

After a terrific first week at EPiServer Denmark, I'm off for a 3-day introduction tour to the swedish HQ.
In the first week I accomplished most of what I set out to do: I got my laptop up and running, with a decent dev. environment, almost learned my way around Vista (still don't know if I like it) and got started on a couple of really interesting projects.

I've also started an episerver-based blog on the Research site, - but don't worry, I plan to crosspost a lot so you shouldn't be missing out on anything here.
So far EPiServer seems to be both a great product and a really nice company - I certainly can't complain about the way I've been received so far.

So, now all thats left to do is to look forward to some of the famous swedish cuisine in the next 3 days to come...

Monday, October 1, 2007

First Day on the new Job

Today was my first day at the new job at EPiServer, and I must say that the future is looking bright!
A lot of new cool hardware had arrived for me (in fact, I'm posting this from my new Lenovo T61p laptop) and - yes, I've taked the step to Vista (finally).
So, naturally I spend a lot of day unpacking hardware, installing and learning my way around Vista (only made it crash twice).
I also had a chance to discover what some of the first tasks for me will be, after I have my dev-environment set up and memorized all of the EPiServer API by heart. It looks like I'll get to play around a little with building a wiki for EPiServer (there seems to be a demand) and I also get to finish a little project that I already started some days ago, making a Mail2EPiPages job. I'll try to post a little more - but don't be surprised if it's all EPiServer specific. Although I'll try to cross-post a lot of my posting will probably be on a blog on the EPiServer Research site.

I owe a big thanks to the great welcome I've received so far at EPiServer - and EPiServer Denmark (THANKS Michael!). I really have a good feeling about my future in this company...