Hmm the package should work. If you want to do it with events you can do this:
public class DigiApplicationBase : ApplicationBase
{
/// <summary>
/// Set all the events which need to be handled. The constructor is called on application start.
/// </summary>
public DigiApplicationBase()
{
Document.New += new Document.NewEventHandler(Document_New);
}
#region Events
/// <summary>
/// This method get's called if a new document is created.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Document_New(Document sender, NewEventArgs e)
{
if (sender.getProperty("currentDate") != null)
{
//If the Document has a property with the name 'currentDate' set it to the current date.
sender.getProperty("currentDate").Value = DateTime.Now;
}
}
#endregion
}
I still think that probably it would be better worth to invest some efforts to fixing the bug once than to create new and new custom solutions for the problem on end - it's opensource anyway...
Events: assign a property after document creation
Hi.
I want to assign a property called "pageBrowserTitle" the document name right after it is created.
I think I should use the after_save event but how can I get the document name in this event ?
something like :
sender.getProperty("pageBrowserTitle").Value = sender.name;
Hi. It looks like what you want is already implemented in the "Standard values" package.
Thanks, Exactly what I needed !
I tried the package, but it isn't working as expected, so is there a way to do it with events nonetheless ? it really should be a simple task right ?
Hmm the package should work. If you want to do it with events you can do this:
Here you can find more info about events: http://www.richardsoeteman.net/2009/02/22/UmbracoV4EventsDemo.aspx
Jeroen
And this one will work for what you need:
Jeroen
Yeah, of course it's possible - ultimately "Standard values" work on events anyway. I've done the things already by hand - below is a snippet:
I still think that probably it would be better worth to invest some efforts to fixing the bug once than to create new and new custom solutions for the problem on end - it's opensource anyway...
is working on a reply...