This can be easily done using Events, on Document.New
http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events
Just create a new class (e.g. UmbracoEvents.cs)
using System;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;
using Examine;
public class UmbracoEvents: ApplicationBase
{
public UmbracoEvents()
{
Document.New += new Document.NewEventHandler(Document_New);
}
private void Document_New(Document sender, umbraco.cms.businesslogic.NewEventArgs e)
{
if (sender.ContentType.Alias == "News")
{
sender.getProperty("date").Value = DateTime.Today;
}
}
}
source
share