Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • pat 124 posts 346 karma points
    Feb 24, 2012 @ 16:25
    pat
    0

    on create page assign node name to a document property

    I need to assign node name to PageTitle and Menu Title properties which are defined in document property.

    how do I make this happen automatically, when type name for new page and press create.

    please

     

  • Seth Niemuth 275 posts 397 karma points
    Feb 24, 2012 @ 16:56
    Seth Niemuth
    0

    This package lets you have default values for properties for different document types:

    http://our.umbraco.org/projects/developer-tools/standard-values-in-umbraco

    Is that what you want?

  • pat 124 posts 346 karma points
    Feb 24, 2012 @ 17:36
    pat
    0

    I saw that already but why that shows another tree node  call standard values under neeth Document types  in settings section. is there any way to do this with a code plugin ?

     

     

  • Seth Niemuth 275 posts 397 karma points
    Feb 24, 2012 @ 17:51
    Seth Niemuth
    0

    What do you mean by code plugin? The reason it exists in settings section is that it corresponds exactly to your document types. What makes you not want to use this?

  • gilad 185 posts 425 karma points
    Feb 24, 2012 @ 18:08
    gilad
    0

    1) Create new Class Library project , create class.

    2) Add this referance to project from some umbraco site bin folder -
             cms.dll,
             businesslogic.dll,
             umbraco.dll
             interfaces.dll

    3) In your class use this code :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using umbraco.cms.businesslogic.web;
    using umbraco.BusinessLogic;
    
    
    namespace custom_events
    {
        public class assignName : umbraco.BusinessLogic.ApplicationBase 
        {
            public assignName() {
                Document.New += new Document.NewEventHandler(Document_New);
            }
    
            void Document_New(Document sender, umbraco.cms.businesslogic.NewEventArgs e)
            {
                if (sender.ContentType.Alias == "page") /// your document type alias
                {
                    sender.getProperty("pageTitle").Value = sender.Text;
                    sender.getProperty("menuTitle").Value = sender.Text;
                }
            }
    
        }
    }
    
    

     

    4) Build your project and add referance in your umbraco project or copy the dll file to umbraco site bin folder.

     

     

  • pat 124 posts 346 karma points
    Feb 24, 2012 @ 18:32
    pat
    0

    thanks found the error , I have used sender.getproperty(name).Value;  assuming that I can read page name like that.

    once changed to sender.Text;

    my code works, brilient...

    thanks again

     

Please Sign in or register to post replies

Write your reply to:

Draft