Copied to clipboard

Flag this post as spam?

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


  • Ayo Adesina 419 posts 1001 karma points
    Sep 05, 2011 @ 01:30
    Ayo Adesina
    0

    Populate drop downlist with umbraco node names

    Hi I have got a user contorl that is nicely rendering on the screen via a macro in umbraco.

    But I want one of the felds on the form wich is a drop down list to be pre-populated with the names of some nodes that are in my content of my umbraco website, can someone please point me in the right direction.

     

    Thanks

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    Sep 05, 2011 @ 01:48
    Hendy Racher
    0

    Hi Avo,

    Do you mean a DropDownList on within Umbraco ? if so you could look at using the UltimatePicker or the XPath DropDownList (which is in uComponents)

    HTH,.

    Hendy

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 05, 2011 @ 04:41
    Fuji Kusaka
    0

    Hi Ayo,

    You can try wrapping your select around a loop and get it to trigger like that

    <select name="Name" id="yourId" onChange="window.open(this.options[this.selectedIndex].value,'_self')">
      <option value="/">Make a choice</option>
        <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
          <option value="{umbraco.library:NiceUrl(@id)}">
              <xsl:value-of select="@nodeName"/>
          </option>
      </xsl:for-each>
    </select>

  • Ayo Adesina 419 posts 1001 karma points
    Sep 05, 2011 @ 20:42
    Ayo Adesina
    0

    Sorry if my intial question was unclear, let me try again.

    I have a form which is a user control (.ascx file) and this usercontrol has been placed on a template, the form is rendering fine at the moment.

    What I want to do is, load one of the form controls a drop down list with a list of node names.

    I assume from the xslt above provided by Fuji I will have to use a umbrco library method to retrive the required data on the page_load event of my user control then use a loop to add them to my drop down list.........am I right?

    any c# code welcome ;-)

    Thanks

  • Ayo Adesina 419 posts 1001 karma points
    Sep 05, 2011 @ 21:19
    Ayo Adesina
    0
    using umbraco.presentation.nodeFactory;
    Node node = new umbraco.presentation.nodeFactory.Node(NODEIDHERE);
    Nodes childrenNodes = node.Children;
    This is the answer by the way I found it on another post. I thought it would be good to post the asnswer just in case someone else needs help.
  • Ayo Adesina 419 posts 1001 karma points
    Sep 05, 2011 @ 21:53
    Ayo Adesina
    0

    I'm back 30mins later with my begging bowl, Yes I am getting the nodes that I want back, but I can't find where the name of the node will be so I can do some kind of loop and add the names of the nodes to a drop down list........

     

    hellllppppppppp

     

    thanks ;-)

  • Ayo Adesina 419 posts 1001 karma points
    Sep 05, 2011 @ 22:01
    Ayo Adesina
    0
    private void DoSomethingWithAllNodesByType(int NodeId, string typeName) { var node = new Node(nodeId); foreach (Node childNode in node.Children) { var child = childNode; if (child.NodeTypeAlias == typeName) { //Do something } if (child.Children.Count > 0) GetAllNodesByType(child, typeName); } }
    OK Fixed my own problem again.....Hope someone else finds this...who needs it chow.
  • Lee Kelleher 3945 posts 15163 karma points MVP 10x admin c-trib
    Sep 05, 2011 @ 22:18
    Lee Kelleher
    0

    Hey Ayo,

    If you are using the uComponents package, then be sure to take a look at the uQuery library methods - they may just make your dev time easier? http://ucomponents.codeplex.com/wikipage?title=uQuery

    We have a method called "uComponents.Core.uQuery.GetNodesByType(string documentTypeAlias)" ... this will get all the nodes for that doc-type alias.  But if you need to do something more complex, say getting all child-nodes of a certain doc-type, then you could do this using an XPath ...

    var nodes = uQuery.GetNodesByXPath(string.Concat("descendant::*[@id = ", nodeId ,"]/descendant::", documentTypeAlias, "[@isDoc]"));

    Cheers, Lee.

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Sep 05, 2011 @ 22:22
    Jeroen Breuer
    1

    Have a look at this wiki post: http://our.umbraco.org/wiki/reference/code-snippets/databind-node-children. It shows 3 ways to databind the children to a checkboxlist. You can also use it for a dropdownlist.

    Jeroen

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies