Copied to clipboard

Flag this post as spam?

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


  • Nami Nasserazad 23 posts 43 karma points
    Dec 23, 2010 @ 11:24
    Nami Nasserazad
    0

    Default Value in Document Type Field

    Hi

    I would like to have a date time field in a document type which when I create a content based on document type, the default value of this date time field is set to NOW as default.

    Regards,

    Nami

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Dec 23, 2010 @ 11:28
    Hendy Racher
    0

    Hi Nami,

    Check out the Standard Values package, although you can also acheive this with an Event Handler to set the value on save.

    HTH,

    Hendy

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Dec 23, 2010 @ 11:29
  • Nami Nasserazad 23 posts 43 karma points
    Dec 23, 2010 @ 13:31
    Nami Nasserazad
    0

    Would you please explain me how I should use it! The description is a bit vague for me!

    I would like to say again that I want to have a field in my content which is initialized by a default value to simplify the work of CONTENT EDITOR.

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Dec 23, 2010 @ 13:34
    Darren Ferguson
    0

    Which part do you not understand?

  • Nami Nasserazad 23 posts 43 karma points
    Dec 23, 2010 @ 13:39
    Nami Nasserazad
    0

    Currently, I have a content called newsItem which has a field relating to its publishing date. I would like it to have default value (set as current date time) to simplify the content editor task.

    How can I change this current content using your package. Since this is a live web site with too much content!

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Dec 23, 2010 @ 13:46
    Darren Ferguson
    0

    I didn't develop the package - I am just recommending it.

    I don't believe that the package works with existing content (you didn't mention that before).

    Umbraco already stores createDate and updateDate properties, why don't you just use these?

     

     

  • Nami Nasserazad 23 posts 43 karma points
    Dec 23, 2010 @ 13:48
    Nami Nasserazad
    0

    Because for example we create a news as a content but we want it to publish tomorrow! Then we set the publication date properties of that to tomorrow and it will be published then!

    We cannot use createDate and updateDate since we do not want to always use current date!

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Dec 23, 2010 @ 13:57
    Hendy Racher
    0

    Hi Nami,

    In that case, you don't need any 3rd party packages as that functionality is built-in.

    On the properties tab of your news item, you'll see a publish at field with a date picker.

    HTH,

    Hendy

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Dec 23, 2010 @ 14:01
    Darren Ferguson
    0

    Before you said you wanted the value set to NOW when the node is created. You have changed your mind and are now saying that you want to store the actual publish date.

    Which is correct?

    For the former @createDate is sufficient.

    For the latter you'd want a Document.AfterPublish event to set the document property to DateTime.Now

    In both cases I'm not sure how you'd grab the publish date retrospectively for existing data.

     

  • Nami Nasserazad 23 posts 43 karma points
    Dec 23, 2010 @ 14:02
    Nami Nasserazad
    0

    Yes, But how can I set custom value to that as a default. For example I want as default all of news that I create will publish tomorrow!

    Cheers

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Dec 23, 2010 @ 14:04
    Darren Ferguson
    0

    So what you want is to set a default value for the built in "Publish at" property?

  • Nami Nasserazad 23 posts 43 karma points
    Dec 23, 2010 @ 14:12
    Nami Nasserazad
    0

    Darren

    I did not change my mind! The customer wants us to have default value for publication date and they want this default value be flexible. For some kinds of news, they mostly should be published immediately, for another category, mostly they have to be announced the next working day or simply tomorrow.

    Then I would like to have a facility to set a default value for one field! For example, when I create a field for document type, In addition to add validation, description and etc. I have this facility to mention a default value as an expression.

    Regards,

     

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Dec 23, 2010 @ 14:20
    Darren Ferguson
    0

    Well - If you want to specify a default value when you create the doc type you'd need to create a custom datatype - http://www.nibble.be/?p=62 (be aware that 4.6 will change how this is done to some extent).

    If you want to get Umbraco to publish the node based on the value of your custom datatype you'd need a Document.BeforePublish event to check the value of your field and either proceed with the publish or set the ReleaseDate property of the Doucment to a future date and cancel the underlying event.

    HTH

  • Eran Meir 401 posts 543 karma points
    Dec 23, 2010 @ 14:23
    Eran Meir
    0

    i did another thing for custom value, here's my example, hope it helps

    public class BlogPostHandler : ApplicationBase
        {
            public BlogPostHandler()
            {
                Document.New += new Document.NewEventHandler(Document_New);
            }
            void Document_New(Document sender,NewEventArgs e)
            {
                if (sender.ContentType.Alias == "YOUR DOCUMENT TYPE")
                {
                    try
                    {
                        sender.getProperty("postDate").Value = DateTime.Now;
                    }
                    catch
                    {
                        
                    }
                }
            }
        }

  • Nami Nasserazad 23 posts 43 karma points
    Dec 23, 2010 @ 14:23
    Nami Nasserazad
    0

    Well, I think the custom data type with custom renderer is the thing that I am looking for. Thank you.

    Regards,

    Be cool ;)

  • Nami Nasserazad 23 posts 43 karma points
    Dec 23, 2010 @ 14:26
    Nami Nasserazad
    0

    Yap! I think this is simpler! But user could not set the default value in document type definition. 

Please Sign in or register to post replies

Write your reply to:

Draft