Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: CategoryList in a DropDownList?

  1. #1
    Join Date
    Jun 2009
    Posts
    191

    Default CategoryList in a DropDownList?

    Hey all,

    I was wondering if there is a way to dynamically populate a dropdownlist in an XML Package? I want to have a dropdownlist at the top of our page... For example:

    Say from the home page you go to Bedrooms. Then in there, you have a product listing of all bedroom furniture. On that page, I would like to have a dropdownlist control with each subcategory, say like:

    Master Bedroom
    Youth Bedroom
    Day Beds

    etc...

    Does anyone know how to accomplish this?

    Cheers,

    D

  2. #2
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    873

    Default

    Sure - it's really easy.
    The best example I can think of is in product.variantsindropdown.xml.config

    It creates a dropdown for variants rather than categories - but it demonstrates the concept of building a dropdown really well.


    TTFN

    BFG

  3. #3
    Join Date
    Jun 2009
    Posts
    191

    Default

    Quote Originally Posted by BFG 9000 View Post
    Sure - it's really easy.
    The best example I can think of is in product.variantsindropdown.xml.config

    It creates a dropdown for variants rather than categories - but it demonstrates the concept of building a dropdown really well.


    TTFN

    BFG
    I will take a look.

    Thank you VERY much!

  4. #4
    Join Date
    Jun 2009
    Posts
    191

    Default

    Quote Originally Posted by BFG 9000 View Post
    Sure - it's really easy.
    The best example I can think of is in product.variantsindropdown.xml.config

    It creates a dropdown for variants rather than categories - but it demonstrates the concept of building a dropdown really well.


    TTFN

    BFG
    Ok. This may be really easy for you, but for me... not so much.

    Do you think you could show me how I would put this in the entity.grid.xml.config file please? I would like the dropdown at the top of the page - above the products.

  5. #5
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    873

    Default

    OK, add a new template to your xmlpackage like this :-


    C#/VB.NET Code:
                <xsl:template name="BFG-DropDown">
    <
    select>
    <
    option value="Select">Select One</option>
                    <
    xsl:for-each select="/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[ParentEntityID=/root/Runtime/EntityID]">
    <
    xsl:variable name="scName" select="aspdnsf:GetMLValue(Name)"></xsl:variable>
    <
    option value="{aspdnsf:EntityLink(EntityID, SEName, $EntityName, 0, '')}"><xsl:value-of select="$scNamedisable-output-escaping="yes"/></option>
                    </
    xsl:for-each>
    </
    select>
                </
    xsl:template
    & then call it where you want the dropdown to appear like this :-

    C#/VB.NET Code:
    <xsl:call-template name="BFG-DropDown" /> 


    N.B. This doesn't actually do anything - it just puts the dropdown onto the page.



    TTFN

    BFG

  6. #6
    Join Date
    Jun 2009
    Posts
    191

    Default

    Quote Originally Posted by BFG 9000 View Post
    OK, add a new template to your xmlpackage like this :-


    C#/VB.NET Code:
                <xsl:template name="BFG-DropDown">
    <
    select>
    <
    option value="Select">Select One</option>
                    <
    xsl:for-each select="/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[ParentEntityID=/root/Runtime/EntityID]">
    <
    xsl:variable name="scName" select="aspdnsf:GetMLValue(Name)"></xsl:variable>
    <
    option value="{aspdnsf:EntityLink(EntityID, SEName, $EntityName, 0, '')}"><xsl:value-of select="$scNamedisable-output-escaping="yes"/></option>
                    </
    xsl:for-each>
    </
    select>
                </
    xsl:template
    & then call it where you want the dropdown to appear like this :-

    C#/VB.NET Code:
    <xsl:call-template name="BFG-DropDown" /> 


    N.B. This doesn't actually do anything - it just puts the dropdown onto the page.



    TTFN

    BFG
    That's awesome! Do you know how I would populate that dynamically with the sub-categories or departments and assign or append the URL to them too?

    Thanks again!

  7. #7
    Join Date
    Jun 2009
    Posts
    191

    Default

    Quote Originally Posted by BFG 9000 View Post
    OK, add a new template to your xmlpackage like this :-


    C#/VB.NET Code:
                <xsl:template name="BFG-DropDown">
    <
    select>
    <
    option value="Select">Select One</option>
                    <
    xsl:for-each select="/root/EntityHelpers/*[name()=/root/Runtime/EntityName]/descendant::Entity[ParentEntityID=/root/Runtime/EntityID]">
    <
    xsl:variable name="scName" select="aspdnsf:GetMLValue(Name)"></xsl:variable>
    <
    option value="{aspdnsf:EntityLink(EntityID, SEName, $EntityName, 0, '')}"><xsl:value-of select="$scNamedisable-output-escaping="yes"/></option>
                    </
    xsl:for-each>
    </
    select>
                </
    xsl:template
    & then call it where you want the dropdown to appear like this :-

    C#/VB.NET Code:
    <xsl:call-template name="BFG-DropDown" /> 


    N.B. This doesn't actually do anything - it just puts the dropdown onto the page.



    TTFN

    BFG
    Ok. Sorry... I see the items are there, but could you tell me please how to have them go to their pages?

  8. #8
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    873

    Default

    Erm...

    That's what it does!

  9. #9
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    873

    Default

    Ahh OK - you'd need to use some javascript on the 'onchange' event for the dropdown.

    A quick look on google gave me this & this.




    TTFN

    BFG

  10. #10
    Join Date
    Jun 2009
    Posts
    191

    Default

    Quote Originally Posted by BFG 9000 View Post
    Ahh OK - you'd need to use some javascript on the 'onchange' event for the dropdown.

    A quick look on google gave me this & this.




    TTFN

    BFG
    Ok. Sorry to be a pain, but where would I put that in the template?

    Thanks again! You have been a tremendous help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •