Zoeken

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Last week Warren Buckley asked for a URL Rewrite Action to use in his awesome next version of the Umbraco Creative Website Starter site (if Warren release it make sure you download it, it's great!!). I was already thinking of creating some sort of packactions library so I started working on that a little bit sooner (and more in a hurry) than expected. The result is a new Codeplex project called Package Actions Contrib that will hopefully be used by the community and I'm also hoping for a lot of contributors that will be part of this project.

Package Actions?

Package actions are great to include some custom functionality during the install of your package, just by implementing the IPackageAction interface and the use of Package XML in the package creator. This PDF describes all default package actions that are included in the V4 release of umbraco and it also describes how to use them.

AddUrlRewriteRule Action

Currently only one package action is included in the project. That is the AddUrlRewriteRule Action. With the AddUrlRewriteRule you can add a new rewrite rule to the UrlRewriting.config file. The xml snippet below descibes the xml for adding the UrlRewrite rule to the config file. The action element is the normal element that you must include for each package action. The Alias is the alias that is used in the AddUrlRewriteRule class. The undo option is implemented but will not work because of this bug I recently found. And the add element is what you normally will add manually in the UrlRewriting.config file.

The next thing that will be added to the project is not a new action but it will be a tool where you can test your package action and package action xml without actually having to install a package. Instead you can upload the dll and enter the xml and press the testbutton to validate that the action installed or uninstalled correctly or what errors did occur. Also I like to have some documentation in the way that the normal package actions are described.

Contribute to the project

I think this project can only be a success with help from the community. So if you have some really cool custom package action now that could be useful to share please apply a patch on Codeplex or contact me by mail, also if you just have a great idea that could be included in the project.

Click here to visit the Codeplex project site. Hope to see some really nice package actions included in the contrib.

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Yesterday I gave a demo about events in Umbraco V4. I did this by describing a few "Business problems" that could be solved using events. A few facts about events in Umbraco V4:

You find events on every Component in Umbraco.

To uses events, you need references to the businesslogic, cms and interfaces assemlies.

To use events, you have to create a class that uses umbraco.BusinessLogic.ApplicationBase as the base class. In the constructor you can wire up the event handler. These classes will be automaticly picked up when you put the file in the App_Code folder of Umbraco or put the compiled DLL in the bin folder of Umbraco. I prefer the last one.

Most of the event args derive from CancelEventArgs, so we can cancel the operation.

Because an event executes in the background you should always document that you're using events and make sure you will write a logmessage when you're event handler gets executed.

For my demo's, I've used an Umbraco V4 installation with the Creative Website Wizard installed.

Demo 1 Auto Expire news

In the first demo.I've showed how the document.BeforePublish can be used to check if a news item is allready expired, if so cancel the publish event, otherwise check if the expire date is set and if not, set the expire date to 14 days from now.

40: //Date is not set set it now and save the doc. Probably better to to this in the before save event

41: //since this is a demo it's allowed to do it here

42: sender.ExpireDate = DateTime.Now.AddDays(14);

43: sender.Save();

44:

45: }

46: }

47: }

48: }

49: }

During this demo someone asked if it's possible to show a custom message in the speechbubble event when an event is canceled. This is not possible (tested it this morning), I've created an item on CodePlex.

Demo 2 Auto archive news

In this Demo I've created some functionality to automaticly move a news item to the archive folder when a content manager sets the archive boolean to true. First an archive boolean must be added to the news document and a new Archive folder must be created where we can store the archived News items in.

Demo 3 Add Unpublish menu Item to the Context menu

In this demo I've showed that we can use events to modify the context menu. I'm missing a unpublish item in the context menu. This example is a little bit harder because we we need to create a menu item also. A menu item can be created to create a class that derives from the IAction interface. I will leave the explanation of this interface for a future blogpost.

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Last friday I've blogged about Macro Picker and got a few emails asking to make the source available to make (small) modifications. I'm very pleased to announce that the project is now available on Codeplex. The license is MIT now so you can basically do everything with it. You can find the project on www.codeplex.com/macropicker

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Recently I started working with Design Revolution as a partner on Umbraco projects. Together we released a few sites and all these sites contained a section where a user can pick dynamic elements such as overviews, map locations etc. To achieve this we've created a few macro's that contained functionality to display the correct information. For each section where the user can select a macro we've created a tab(overview1/overview2 etc) with a Rich Text Editor to selected the macro. We came to the conclusion that this isn't the best solution because we want to force site integrity and we came up with the idea to create a datatype where a user can select a macro and fill in the macro properties as normal Umbraco data fields.

How it works

In the video below I will demonstrate how the datatype works. I've installed a clean Umbraco installation with Runway and the following Runway modules installed

Runway FAQ Module

Runway JCarousel

Standard Top Navigation

I did modify the macro's a bit so that they accepted a content picker macro parameter so we can list the selected folder instead of the current folder. When you want to use the package it's good to know that you can use the normal syntax for a page item, all options that you can choose on a normal Text datatype will also work on the Macro Picker datatype.

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

One of the things I like most about Umbraco is that you can extend it in a way that your custom functionality has exactly the same behaviour as the standard Umbraco functionality. The biggest compliment you can get from a user is when they say "I found a bug in Umbraco" while it's your own control (or love the way Umbraco works when it's your own control).. One of the things to achieve that is to use the same mechanism to show messages to the user as Umbraco does. In this post we create a simple user control where the user can type a message and we will show that message using the Umbraco Speech bubble mechanism as shown in the image below.

To build this we need to create a standard WebUserControl called SpeechBubble.ascx. In the ascx file we add the following code that creates the UI and hooks up an Event Handler for the submit button.

We will run this code as an Dashboard Control which runs in the Umbraco context. Therefore we can cast the Page Type to a the Umbraco BasePage type and then use the speechBubble method which displays the message. If you want to play with this yourself, you can download the usercontrol here. Add the files in this zip file to the UserControl folder of Umbraco and Modifiy the Dashboard.Config file which you can find in the Config folder:

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Content Maintenance Dashboard is a simple package to bulk publish, unpublish and delete content items based on name,state and document type. When you install it and go to the developer section of Umbraco you can see the search screen like the image below. From the search results screen you can perform actions on a single Item or you can choose to perform the same action on all the items in the search result.

The package is using sql to search for the documents. I'm using the new datalayer so it should be working on any type of database that is supported by Umbraco, however I only tested the package on SQL Server. I have tested this package also on the Umbraco RC3 release(this is probably the first package that is compiled against the RC3 Binaries). You can download the package here, if you want the complete source code you can download it here.

The package was based on Beta1 of Umbraco 4 and threw errors when installing on Umbraco 4 RC. I've fixed these bugs and created a new package. Currently I'm also working on a new version that is capable of importing members and I will add support for plugging in your own datasource, so you can import data from any datasource you like.