Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CreateSite : Command
- {
- //protected void CreateSite()
- //{
- // //Change the eventName here
- // SheerResponse.Timer("multisite:createSiteA", 100);
- //}
- public static string InvalidPath = "/sitecore/templates/Branches/Project/Common/Sites/Site Root";
- public override void Execute(CommandContext context)
- {
- if (context.Items.Length == 1)
- {
- var item = context.Items[0];
- var parameters = new NameValueCollection();
- parameters["id"] = item.ID.ToString();
- parameters["language"] = item.Language.ToString();
- parameters["database"] = item.Database.Name;
- Sitecore.Context.ClientPage.Start(this, "Run", parameters);
- }
- }
- protected void Run(Sitecore.Web.UI.Sheer.ClientPipelineArgs args)
- {
- if (!args.IsPostBack)
- {
- //Means we are in the initial step, we want to ask for the name of the news
- Sitecore.Context.ClientPage.ClientResponse.Input("Enter site name:",
- Sitecore.Globalization.Translate.Text("Site Name"),
- Sitecore.Configuration.Settings.ItemNameValidation, "'$Input' is not a valid name.", 100);
- args.WaitForPostBack();
- }
- else
- {
- //Now we got a postback, which means we got a response
- if (!String.IsNullOrEmpty(args.Result) && args.Result != "undefined")
- {
- var db = Sitecore.Configuration.Factory.GetDatabase(args.Parameters["database"]);
- var parent = db.GetItem(args.Parameters["id"], Language.Parse(args.Parameters["language"]));
- BranchItem branch = parent.Database.GetItem(Constants.BranchSite.SiteA);
- var item = parent.Add(args.Result, branch);
- // DO YOUR WORK HERE
- Sitecore.Context.ClientPage.SendMessage(this, "item:load(id=" + item.ID + ")");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement