Copied to clipboard

Flag this post as spam?

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


  • Phil Crowe 192 posts 256 karma points
    Mar 24, 2010 @ 16:11
    Phil Crowe
    0

    XSLT with .NET Dropdown

    Hi, still pretty new to xslt and ive looked through the umbraco documentation but cant find an answer to this. If i have two .net dropdown controls on a page that reference properties of a document type, and i want to create a xlst foreach loop that looks at what has been selected in both drop down menus and displays the nodes according to what has been selected? For example, one property of a document type is colour another property is size, a node has been created and its colour is set as brown and size is medium. On the front end the colour brown has been selected in the drop down and size 7 has been selected in the other drop down. I want the page to then filter to show these nodes in the list of results on the page. Can someone point me in the right direction

    Thans

    Phil

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 24, 2010 @ 16:25
    Dirk De Grave
    0

    Hi Phil,

    It all depends a bit on how you've setup the dropdowns on the frontend? Do you get the values from the datatype? And how did you select the values in the admin backend? Is it a text string or a new dropdown datatype (for colour and size)?

    If using dropdown datatypes in backend, be aware that the value of the property on the document will be an integer rather than the text (as shown in the dropdown)

    If you're using xslt, you could do a for-each and check the value of the document properties against the value of the dropdowns

    <xsl:for-each select="$currentPage/node [@nodeTypeAlias = 'alias' and string(./data [@alias = 'colour']) = x and string(./data [@alias = size] = y)]">
    ...
    </xsl:for-each>

    (code needs to be verified, writing this on top of my head)

    Let us know if that helps and if not, tell us a bit more on your setup

     

    Cheers,

    /Dirk

  • Phil Crowe 192 posts 256 karma points
    Mar 24, 2010 @ 17:00
    Phil Crowe
    0

    The dropdown on the front end is just using standard ListItems I didnt realised i could get the values from the datatypes. That might be better. I had pretty much the same loop already setup but how do I link this to the value of the asp.net dropdownlist?

  • Phil Crowe 192 posts 256 karma points
    Mar 24, 2010 @ 18:09
    Phil Crowe
    0

    I think my response might have been a little confusing.

    If i have a drop down field on a page like this: 

     

    <asp:DropDownList ID="color" runat="server" >
    <asp:ListItem Text="brown" />
    <asp:ListItem Text="yellow" />
    <asp:ListItem Text="red" />
    </asp:DropDownList>

    how can i make the xslt recognise what has been selected

     

    <xsl:for-each select="$currentPage/node [@nodeTypeAlias = 'alias' and string(./data [@alias = 'colour']) = SELECTED COLOR DROP DOWN MENU?????  ]">
    ...
    </xsl:for-each>

     

     

Please Sign in or register to post replies

Write your reply to:

Draft