Our Forum has Moved

This site is our old forum and is only here for achive until we get proper 301 redirects setup to make Google happy.

Please use our new community site - Our Umbraco - which contains an improved forum, documentation wiki, package repository and a member locator.

Go to Our Umbraco now

Learn everything about Umbraco
V4: Package Actions Options
pmarden
Posted: Wednesday, February 25, 2009 1:12:18 PM

Rank: Devotee

Joined: 11/12/2008
Posts: 66
Location: Bracknell - UK
Dirk,

Thanks for the reply.

Writing a package action seems like a good medium term solution, but in the sort term does anyone have any suggestions about how, during the install part of a package, you could update a DataType to include a new allowed template.

P
rsoeteman
Posted: Wednesday, February 25, 2009 2:01:27 PM

Rank: Fanatic

Joined: 4/3/2008
Posts: 269
Location: The Netherlands
Hi,

The medium term solution is also the short term solution. What you have to do is to create a new class that implements IPackageAction

In the execute method put the code to add the allowed action.

Code:

    public class MyGreatInstallerAction : IPackageAction
    {
        /// <summary>
        /// Install something
        /// </summary>
        public bool Execute(string packageName, XmlNode xmlData)
        {
          //Add new allowed document type documentType.AllowedTemplates.add .......
         return true; //Succeeded
        }
        /// <summary>
        /// UnInstall Something
        /// </summary>
        public bool Undo(string packageName, XmlNode xmlData)
        {

            return true; //Succeeded
        }
       
        /// <summary>
        /// PackageAction Alias
        /// </summary>
        /// <returns></returns>
        public string Alias()
        {
            return "MyGreatInstallerAction ";
        }

        /// <summary>
        /// SampleXML
        /// </summary>
        /// <returns></returns>
        public XmlNode SampleXml()
        {

            string sample = "<Action runat=\"install\" undo=\"true/false\" alias=\"MyGreatInstallerAction \"/>";
            return helper.parseStringToXmlNode(sample);
        }
    }


When you create the package you must include the DLL that contains this class, it will be picked up automatically. Then you go to the Package Action section and you include this xml
Code:
<Action runat="install" undo="true" alias="MyGreatInstallerAction " />


Make sure that the alias in the xml matches the alias from the Class. Otherwise umbraco will not execute this Package Action

This is the sort term solution. The long term solution would be to have some attributes on the xml node that describe which template alias or whatever must be added to a document type.

Hope this helps.

Richard



level 2 certified - Umbraco development - Soeteman Software

Import data into Umbraco? Consider using UmbImport
hans
Posted: Wednesday, May 13, 2009 3:33:07 PM
Rank: Newbie

Joined: 12/21/2008
Posts: 13
Location: Netherlands
Hi Richard,

Thanks for your helpful example. Unfortunately my "Undo" method never gets hit. Did you encounter this same problem? I am currently working with v4.0.1. Is this maybe a bug? Anyway, it would be great if I get my uninstaller working as wel as my installer.

Hope you can help me.
rsoeteman
Posted: Thursday, May 14, 2009 9:14:15 AM

Rank: Fanatic

Joined: 4/3/2008
Posts: 269
Location: The Netherlands
Hi Hans,

Leave the Undo attribute out of the tag and see what happens.

Cheers,

Richard

level 2 certified - Umbraco development - Soeteman Software

Import data into Umbraco? Consider using UmbImport

The forum has moved

This forum is no longer in use, so you can't reply to this message - please go to Our Umbraco

Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.