I'm currently implementing a translation solution where I use the standard values package, to maintain an original language standard that needs to be translated.
I have a custom datatype with 2 textfields. One field for the original language and one field for the translated language. They're saved as 2 strings separated with a '|' character.
I wanted to know if its possible to retrieve the standardvalues within my datatype so I can keep the data synchronized with the standard values in case they're updated after the document has been created?
I'm not 100% sure I understand that you are asking. But I can say that the standard values only applies to Document Types. On the Document Types you can specify a key like $key$ which will be replaced by the corresponding value upon creating a new Document based on a certain Document Type.
If you enter a prevalue on your Data Type, and that prevalue is a specified key then that value would show up on your Document Types under the Standard Values section, and when saved it will eventually be replaced by a value when you start creating Documents.
Basically what I want to do is, if somebody changes a standard value I want to update the documents of the specific type. If I open a document in the content tree, my custom datatype will check the document types standard values and update them. If somebody has made changes to the standard value after the document has been created they will appear.
I'm not sure how I specify the specify the $key$ you mention?
With regards to keys, did you check out this screener? http://screenr.com/GP1 and the first screenshot on the package page?
I'm in the process of making version 1.1 and I will make a new screener this saturday, which will hopefully make the use of keys more clear. So lets take it from there.... and I can show you how to lookup standard values for a specific Document Type.
I think i partially found the solution to my problem. In my datatype DataEditor I can fetch the standard value nodeId like this:
Document d = new Document(int.Parse(Request["id"]));
int standardvalue = Sitereactor.StandardValues.businesslogic.StandardValue.GetNodeId(d.ContentType.Id);
umbraco.cms.businesslogic.CMSNode n = new umbraco.cms.businesslogic.CMSNode(standardvalue);
I'm pretty uncertain how I can use this Id to retreive the values from the database, (ie. I can't figure out where they're placed)
I updated the package to version 1.1, added a couple of screeners and the source code for this package. So hopefully this should make it easier for you to sort out your problem. But with regards to the node you are trying to get out in your Data Type, you can load it like this:
ContentItemType contentItemType = new ContentItemType(int.Parse(Request.QueryString["id"])); int nodeId = StandardValue.GetNodeId(contentItemType.Id); ContentItem contentItem = new ContentItem(nodeId);
where the nodeId is the id I use to keep track of Standard Value nodes (the id that is requested is the id of the Document Type). The interesting part about the ContentItem is that it contains a collection or properties, which contains the standard values - these standard values (or properties) will be copied to a Document when creating a new document in the content section.
Does this help answer your questions? I'm still not 100% sure that you can use this package to archive what you are aiming for...(?) but hope it will :)
Get standardvalues in datatype editor?
Great Package!
I'm currently implementing a translation solution where I use the standard values package, to maintain an original language standard that needs to be translated.
I have a custom datatype with 2 textfields. One field for the original language and one field for the translated language. They're saved as 2 strings separated with a '|' character.
I wanted to know if its possible to retrieve the standardvalues within my datatype so I can keep the data synchronized with the standard values in case they're updated after the document has been created?
Best Regards
Sune Fengel
Hi Sune,
I'm not 100% sure I understand that you are asking. But I can say that the standard values only applies to Document Types. On the Document Types you can specify a key like $key$ which will be replaced by the corresponding value upon creating a new Document based on a certain Document Type.
If you enter a prevalue on your Data Type, and that prevalue is a specified key then that value would show up on your Document Types under the Standard Values section, and when saved it will eventually be replaced by a value when you start creating Documents.
Does it make sense?
Please let me know if I misunderstood something.
- Morten
Sorry about my bad phrasing :)
Basically what I want to do is, if somebody changes a standard value I want to update the documents of the specific type. If I open a document in the content tree, my custom datatype will check the document types standard values and update them. If somebody has made changes to the standard value after the document has been created they will appear.
I'm not sure how I specify the specify the $key$ you mention?
Best Regards
-Sune
Maybe even more basically I need to find out what Document type i am on within my datatype.
Something like Node.GetCurrent() then maybe I could look up the cmsstandardvalues table and load the content from there?
- Sune
With regards to keys, did you check out this screener? http://screenr.com/GP1 and the first screenshot on the package page?
I'm in the process of making version 1.1 and I will make a new screener this saturday, which will hopefully make the use of keys more clear. So lets take it from there.... and I can show you how to lookup standard values for a specific Document Type.
- Morten
Sounds great. Thanks.
Pretty neet feature with the keys...
- Sune
Hi again Morten.
I think i partially found the solution to my problem. In my datatype DataEditor I can fetch the standard value nodeId like this:
I'm pretty uncertain how I can use this Id to retreive the values from the database, (ie. I can't figure out where they're placed)
- Sune
Hi Sune,
I updated the package to version 1.1, added a couple of screeners and the source code for this package. So hopefully this should make it easier for you to sort out your problem. But with regards to the node you are trying to get out in your Data Type, you can load it like this:
where the nodeId is the id I use to keep track of Standard Value nodes (the id that is requested is the id of the Document Type). The interesting part about the ContentItem is that it contains a collection or properties, which contains the standard values - these standard values (or properties) will be copied to a Document when creating a new document in the content section.
Does this help answer your questions? I'm still not 100% sure that you can use this package to archive what you are aiming for...(?) but hope it will :)
- Morten
Thanks a lot. It looks like what I need :)
- Sune
Works like a charm.
I ended up doing this in my dataeditor to ensure that I always retreive the current standard values when updating a document.
Thanks once again
- Sune
is working on a reply...