Wednesday, July 25, 2007
Tuesday, July 24, 2007
Thursday, July 12, 2007
Thursday, July 05, 2007
the archive database in sitecore is a feature that's easily missed and not taken full advantage of. how it can work best for you and your solution i'll leave to you to decide, but there is one thing you might get frustrated at, and that's the fact that there's no real Restore functionality available from the content editor.. well, that is, until now :)
Follow these steps and you'll have your very own Restore Now functionality for the archive.
- Create a new command that will handle the restore functionality
- Add the command to the config
- Add a button to the Archive menu that will allow us to trigger the new command
step 1: creating the code for the command
Create a new C# class and name it ArchiveRestoreCommand
add this code:
ArchiveRestoreCommand : Command
public override void Execute(CommandContext context)
// make sure we only run this if we're in the archive database..
disable security to allow restoration of item..
using (SecurityDisabler disabler = new SecurityDisabler())
// find archive item submitted
ArchiveItem archiveItem =
(archiveItem != null)
// reassure the archive is correct..
Sitecore.Data.Archiving.Archive archive = archiveItem.Archive;
// restore item from the archive without removing it from the archive.. (change 'false' to 'true' to remove it)
// broadcast success information..
// broadcast informative error for not being in the correct database..
Context.ClientPage.ClientResponse.Alert("Restoring an item can only be done from the archive database.");
public override CommandState QueryState(CommandContext context)
// only show this action if we're actually in the archive database
protected void Run(Sitecore.Web.UI.Sheer.ClientPipelineArgs args)
Step 2: Add the command
compile the newly created code and open the App_Config\commands.config file and add the following line to it:
<command name="item:restore" type="usoniandream.extensions.ArchiveRestoreCommand,usoniandream.extensions"/>
Step 3: Customizing the Sitecore archive menu
so, now that the above is all taken care of, go into Sitecore and switch to the Core database, then:
- Navigate to Sitecore\Content\Globals\Archives Menu
- Duplicate the Archive Now item and name the new one Restore Now
- Change the appropriate texts.. nice icon would be Network\16x16\server_out.png
- Change the click to item:restore(id=$Target)
Hope you'll find this useful, next archive addition will hopefully be more useful, like a Preview or something..