Automatically create subpage on creation of a page Options
ChristophS
Posted: Wednesday, February 20, 2008 3:18:36 PM
Rank: Devotee

Joined: 2/4/2008
Posts: 38
Hi,

I'm creating a demo site based on Umbraco. On part of the site are so called 'events'. Now for these events you can subscribe. So I have a page with a list of events, under that the several pages for each event, under such an eventpage a page on which someone can subscribe (for which a login is required).
Now my question is if it is possible in any way to automatically create the subscribtion page when I create an eventpage. I have to do this manually each time when adding a new event.
Thanks for any help or ideas!

Greets.
Anders
Posted: Wednesday, February 20, 2008 3:24:56 PM

Rank: Devotee

Joined: 5/24/2007
Posts: 61
Location: Kalix, Sweden
you could proberly use the function built in umbraco that can render your eventpage with a diffrent template, or do you need a actuall page for your subscribe page? If you remove the .aspx after your event page and then add a /YourOtherTemplate.aspx the vent page will be rendered with YourOtherTemplate

Umbraco Certified Professional
tim
Posted: Wednesday, February 20, 2008 3:36:08 PM

Rank: Addict

Joined: 2/19/2007
Posts: 564
Location: Belgium
You can use an actionhandler to auto create a subpage when creating a page.

More info:

http://umbraco.org/documentation/books/creating-and-using-an-action-handler
http://www.dotnetmafia.com/blogs/kevin/archive/2008/02/13/umbraco-action-handlers-101.aspx

Code Snippet:
Code:


using System;
using System.Collections.Generic;
using System.Text;
using umbraco.cms.businesslogic.web;
using umbraco.cms.businesslogic.property;
using umbraco;

namespace TG.Umb.NeutraaladviesActionHandler
{
    class ApNaActionHandler : umbraco.BusinessLogic.Actions.IActionHandler
    {
        string umbraco.BusinessLogic.Actions.IActionHandler.HandlerName()
        {
            return "TG.Umb.NeutraaladviesActionHandler.ApNaActionHandler";
        }
        umbraco.interfaces.IAction[] umbraco.BusinessLogic.Actions.IActionHandler.ReturnActions()
        {
            return new umbraco.interfaces.IAction[] { new umbraco.BusinessLogic.Actions.ActionNew() };
        }

        Boolean umbraco.BusinessLogic.Actions.IActionHandler.Execute(umbraco.cms.businesslogic.web.Document documentObject, umbraco.interfaces.IAction action)
        {
            // Als het een subsite is
            if (documentObject.ContentType.Alias == "SubSite")
            {
                try
                {
                    umbraco.BusinessLogic.User u = new umbraco.BusinessLogic.User(0);
                    int parent = documentObject.Id;

                  
                    string Situation = "Situering";
                    string MoreInfo = "Meer info";
                    string Step = "Stap ";

                    if (documentObject.Parent.Text == "fr")
                    {
                        Situation = "Apercu";
                         MoreInfo = "Plus d' infos";
                         Step = "Étape ";
                    }

                    

                    //create situation doc
                    DocumentType dtSituationPage = new DocumentType(1062);
                    Document dSituationPage = Document.MakeNew(Situation, dtSituationPage, u, parent);
                    dSituationPage.Save();

                    //create more info doc
                    DocumentType dtMoreInfoPage = new DocumentType(1060);
                    Document dMoreInfoPage = Document.MakeNew(MoreInfo, dtMoreInfoPage, u, parent);
                    dMoreInfoPage.Save();
                  
                    //create steps pages
                    for (int i = 1; i <= 5;i++)
                    {
                        DocumentType dtStepsPage = new DocumentType(1070);
                        Document dStepsPage = Document.MakeNew(Step + i.ToString(), dtStepsPage, u, parent);
                        dStepsPage.Save();

                    }
                  

                    
                    





                }
                catch (Exception)
                {
                    return false;
                }
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}



Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
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.