Copied to clipboard

Flag this post as spam?

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


  • CodeMaster2008 151 posts 184 karma points
    Jun 04, 2010 @ 03:37
    CodeMaster2008
    1

    Change property on a new document

    Hi;

    What i wanna do is set the "umbracoNaviHide" property of a new document to "true", so the user doesn't have to do it himself (they keep forgeting).
    I tried to use the "Document.New" event that but since it's my first time with events I'm probably doing something wrong because it's not firing up.
    Maybe something when translating the code from c# (demos/documentation) to vb.net.

    I hope somebody can help me with that one, here is the class:


    Imports umbraco.presentation.nodeFactory
    Imports umbraco.interfaces
    Imports umbraco.cms.businesslogic.web

    Public Class DocumentProperties
    Inherits umbraco.BusinessLogic.Application

    Public Sub New()
    AddHandler Document.[New], AddressOf Document_New
    End Sub

    Private Sub Document_New(ByVal sender As umbraco.cms.businesslogic.web.Document, ByVal e As umbraco.cms.businesslogic.NewEventArgs)

    Select Case sender.ContentType.Alias
    Case "Gallery", "NewsItem"
    sender.getProperty("umbracoNaviHide").Value = 1
    End Select

    End Sub

    End Class

    Basically, what I'm doing is compiling it and copying the dll to the bin folder.

  • CodeMaster2008 151 posts 184 karma points
    Jun 04, 2010 @ 04:02
    CodeMaster2008
    0

    After two hours i realized i inherited from "Application" instead of "ApplicationBase".

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jun 04, 2010 @ 07:58
    Matt Brailsford
    0

    Another option I've used on a couple of projects could be a custom true/false data type that defaults to true, I'll see if I can find the link and post for reference. Matt

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jun 04, 2010 @ 09:55
    Matt Brailsford
    0

    Heres the link to a forum post on how to setup the custom data type (at the bottom)

    http://forum.umbraco.org/yaf_postst7863_Default-property.aspx

    Another option might be the to use the Default DataTypes project

    http://our.umbraco.org/wiki/reference/default-datatypes

    Matt

  • CodeMaster2008 151 posts 184 karma points
    Jun 04, 2010 @ 19:18
    CodeMaster2008
    0

    You right. A custom data type (based on an user control) would be a lot of easy to implement and reuse. Thanks a lot.

  • Bram Loquet 72 posts 102 karma points
    Oct 18, 2010 @ 14:48
    Bram Loquet
    0
                sender.getProperty("blogitemDate").Value = DateTime.Today.ToString("YYYY-mm-dd");

    //var doc = new Document(sender.Id);
    //doc.getProperty("blogitemDate").Value = DateTime.Today.ToString("YYYY-mm-dd");

    thanks for posting you question codemaster,
    this way I found out to set the property of sender instead of making a new document and setting that property.

     

  • Bram Loquet 72 posts 102 karma points
    Oct 18, 2010 @ 14:56
    Bram Loquet
    0

    off the record,
    it's ToString("yyyy-MM-dd") instead of ToString("YYYY-mm-dd")

Please Sign in or register to post replies

Write your reply to:

Draft