Copied to clipboard

Flag this post as spam?

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


  • René Nissen 15 posts 96 karma points
    Jun 19, 2013 @ 14:46
    René Nissen
    0

    Node properties have same id

    Hi Umbraco People

     

    I’m fairly new to Umbraco development and I’m stucked with a problem that I expected to be a simple task, because I get the same ids from two different node properties.

     

    I have a document type (name Frontpage – alias frontpage), which contains a number of properties. Two of those properties are content pickers that links to two internal pages with the ids 1268 and 1269.

     

    To get the urls of the content pickers, I have created a user control with the parameters DocTypeAlias (frontpageAlias) and NodePropertyAlias_ContentPicker (aliasPageA or aliasPageB). When I look up the node with the alias DocTypeAlias then I get the correct node having all the properties as expected, but I can see that both content picker properties has the value 1269 but both properties have the correct aliases - aliasPageA or aliasPageB

     

    I have checked the existence of the properties in the table cmsContent and they both exist with the correct text attached.

     

    Is it wrong to use content picker for this purpose? – and if so: What to do instead?

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 19, 2013 @ 19:17
    Jan Skovgaard
    0

    Hi René and welcome to our :)

    Your scenario sounds like one where it's a good idea to use a content picker - however it would be nice to see some of your code and if you could also let us know what version of Umbraco you're using it will make it a bit easier to give you some pointers.

    Looking forward to hearing from you.

    /Jan

  • René Nissen 15 posts 96 karma points
    Jun 19, 2013 @ 21:15
    René Nissen
    0

    Hi Jan and thanks for replying

     

    I use Umbraco 6.0.5 and here is my user control.

     

            public string DocTypeAlias { get; set; }

            public string NodeProperty_ContentPicker { get; set; }

            protected void Page_Load(object sender, EventArgs e)

            {

                if (!Page.IsPostBack)

                {

                    GetUrl();

                }

            }

     

            private void GetUrl()

            {

                Node docTypeNode = GetNodeByAlias(DocTypeAlias);

     

                if (docTypeNode == null)

                {

                    return;

                }

     

                Property property = (Property)docTypeNode.PropertiesAsList.Find(x => x.Alias.ToLower() == NodeProperty_ContentPicker.ToLower());

                if (property != null)

                {

                    string url = string.Empty;

                    string pageName = string.Empty;

     

                    try

                    {

                        int propertyId = int.Parse(property.Value);

                        url = umbraco.library.NiceUrl(propertyId);

     

                        Node cpValue = new Node(propertyId);

                        if (cpValue != null)

                        {

                            pageName = cpValue.Name;

                        }

                    }

                    catch (Exception)

                    {

                        //Remember to log the error...

                    }

     

                    hyperLink.NavigateUrl = "~" + url;

                    hyperLink.Text = pageName;

                }

            }

    I really hope that you can enlighten me a little... 
  • René Nissen 15 posts 96 karma points
    Jun 20, 2013 @ 10:17
    René Nissen
    0

    I solved the problem by creating a new document type carrying the two content pickers only.

    By doing so my user control were able to read the properties correctly.

    As far as I can see, the records in the database looks similar, so I assume this is an undocumented Umbraco feature :-)

     

Please Sign in or register to post replies

Write your reply to:

Draft