Dirk's right, in this situation I usually end up hard coding defaults into my xslt files and do the checking there.
I thought you could create datatypes that subclass the current ones (textbox, dropdown, etc) but that check a config file for default values on new page creation. Would make a good package...
Dirk, can you add the 'default value of docType properties' idea to codeplex? Just like the description or validation it may not be used often, but would be a huge benefit to have! (guess I've been using umbraco so long I don't even notice these things any more)
you could change the way umbracoNaviHide works easy. Instead of saying: 'Hide in navigation', name it 'Show in navigation' which causes the default to be false. This offcourse means a slight modification to your xslt's where you have to change the != into =
Perhaphs that's a workable solution? At least that's how I abuse it sometimes ;)
This can easily be done with event handlers or old action handlers.
But, default values have long been a request from everyone for a while. The only good way i can see this happening is specifying a default value for the property at document type level. If we do this, its gonna mean a database change for 4.1... doh! so far there's been no db changes for 4.1, this could be the first one :( Unless anyone has a better idea as to where to store a default value?
To solve this (having a checkbox datatype that is already checked on), I used and modified the code foud in this old forum post. This worked perfectly for me. No action handlers needed.
But still I do think a normal default value is not going to help you all the time. I have a lot of customers that are affraid of the Properties tab. So what I normally do is creat a pageTitle property and fill that with the nodeName value. Or I use a publication date property that I fill with the current date. I'm hoping that these scenarios will also be possible when default values will be implemented in Umbraco.
One way to handle this is by creating default values on content nodes in the site structure and use event handlers like the other proposals
-Content --Home ---Page 1 (based on document type NormalPage) ---Page 2 (based on document type NewsPage) --Default values ---NormalPage (based on document type NormalPage) ---NewsPage (based on document type NewsPage)
When creating a new node on the site structure (under Content/Home), an eventhandler should check to see if the newly created node DocumentType exist under Default values. If true, then copy values from the Node under Default values to the newly created node.
I have created a package that adds the ability to create standard values for your document types, since this has long been I requested feature and since no one has already created a package (as far as I know).
And I was able to reuse a lot of the code that is already available in Umbraco, so I only had to create a small table in the db to keep track of the document types.
Any way to change the default value of a property?
How can set the default value of property on a document type. F.ex. setting the umbracoNaviHide to true by default???
You can't actually, unless you modify the core code. It would be great tho to have such functionality...
Cheers,
/Dirk
You could however use event handlers to listen for new events on documents, check current document (and document type) and set some default values.
Dirk's right, in this situation I usually end up hard coding defaults into my xslt files and do the checking there.
I thought you could create datatypes that subclass the current ones (textbox, dropdown, etc) but that check a config file for default values on new page creation. Would make a good package...
Dirk, can you add the 'default value of docType properties' idea to codeplex? Just like the description or validation it may not be used often, but would be a huge benefit to have! (guess I've been using umbraco so long I don't even notice these things any more)
cheers,
doug.
Thanks for the quick replies. Looking forward to see it in a future release ;-)
/Dan
Dan,
you could change the way umbracoNaviHide works easy. Instead of saying: 'Hide in navigation', name it 'Show in navigation' which causes the default to be false. This offcourse means a slight modification to your xslt's where you have to change the != into =
Perhaphs that's a workable solution? At least that's how I abuse it sometimes ;)
Peter
work item created on Codeplex - now go and vote!
Cheers,
/Dirk
This can easily be done with event handlers or old action handlers.
But, default values have long been a request from everyone for a while. The only good way i can see this happening is specifying a default value for the property at document type level. If we do this, its gonna mean a database change for 4.1... doh! so far there's been no db changes for 4.1, this could be the first one :( Unless anyone has a better idea as to where to store a default value?
To solve this (having a checkbox datatype that is already checked on), I used and modified the code foud in this old forum post. This worked perfectly for me. No action handlers needed.
@Dirk Voted
But still I do think a normal default value is not going to help you all the time. I have a lot of customers that are affraid of the Properties tab. So what I normally do is creat a pageTitle property and fill that with the nodeName value. Or I use a publication date property that I fill with the current date. I'm hoping that these scenarios will also be possible when default values will be implemented in Umbraco.
Dirk, I would love that feature. Voted!
Can someone point me at documentation for modifying values using ActionHandlers or UmbracoEvents?
I'd like to set a date to default to the current DateTime if no date is entered.
Hi Peter,
Did you check example 1 of the wiki I've created. I set the expire date there but with a little modification it should work in your case.
Got my vote on codeplex :-)
One way to handle this is by creating default values on content nodes in the site structure and use event handlers like the other proposals
-Content
--Home
---Page 1 (based on document type NormalPage)
---Page 2 (based on document type NewsPage)
--Default values
---NormalPage (based on document type NormalPage)
---NewsPage (based on document type NewsPage)
When creating a new node on the site structure (under Content/Home), an eventhandler should check to see if the newly created node DocumentType exist under Default values. If true, then copy values from the Node under Default values to the newly created node.
Hi Guys,
I have created a package that adds the ability to create standard values for your document types, since this has long been I requested feature and since no one has already created a package (as far as I know).
And I was able to reuse a lot of the code that is already available in Umbraco, so I only had to create a small table in the db to keep track of the document types.
Go check it out:
http://our.umbraco.org/projects/standard-values-in-umbraco
- Morten
Hello,
If anyone needs this still then Here is good article.
is working on a reply...