Copied to clipboard

Flag this post as spam?

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


  • Fengelz 106 posts 221 karma points
    Mar 03, 2010 @ 17:10
    Fengelz
    0

    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

     

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Mar 03, 2010 @ 23:02
    Morten Christensen
    0

    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

  • Fengelz 106 posts 221 karma points
    Mar 04, 2010 @ 09:03
    Fengelz
    0

    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

  • Fengelz 106 posts 221 karma points
    Mar 04, 2010 @ 10:12
    Fengelz
    0

    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

     

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Mar 04, 2010 @ 10:29
    Morten Christensen
    0

    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

  • Fengelz 106 posts 221 karma points
    Mar 04, 2010 @ 10:51
    Fengelz
    0

    Sounds great. Thanks.

    Pretty neet feature with the keys...

    - Sune

     

  • Fengelz 106 posts 221 karma points
    Mar 04, 2010 @ 13:46
    Fengelz
    0

    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:

    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)

    - Sune

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Mar 07, 2010 @ 21:09
    Morten Christensen
    0

    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:

    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 :)

    - Morten

  • Fengelz 106 posts 221 karma points
    Mar 08, 2010 @ 10:50
    Fengelz
    0

    Thanks a lot. It looks like what I need :)

    - Sune

  • Fengelz 106 posts 221 karma points
    Mar 08, 2010 @ 15:52
    Fengelz
    0

    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.

     private void PageLoaded(object sender, EventArgs e)
            {
                try
                {
                    Document doc = new Document(int.Parse(Request["id"]));
    
                    ContentItemType contentItemType = new ContentItemType(doc.ContentType.Id);
                    int nodeId = StandardValue.GetNodeId(contentItemType.Id);
                    ContentItem contentItem = new ContentItem(nodeId);
    
                    Property[] properties = contentItem.getProperties;
                    Translation.Debug(properties.Length + "");
    
                    var property =
                        (from p in properties
                        where p.PropertyType.Alias == this.ID
                        select p).First();
                    this.originalText.Value = property.Value.ToString().Split('|')[0].TrimStart('[').TrimEnd(']');
                }
                catch (Exception ex) { Debug(ex.ToString()); }
            }

    Thanks once again

    - Sune

Please Sign in or register to post replies

Write your reply to:

Draft