Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 14 of 14

Thread: CategoryList in a DropDownList?

  1. #1
    donato is offline Senior Member
    Join Date
    Jun 2009
    Posts
    215

    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
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    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
    donato is offline Senior Member
    Join Date
    Jun 2009
    Posts
    215

    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
    donato is offline Senior Member
    Join Date
    Jun 2009
    Posts
    215

    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
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    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
    donato is offline Senior Member
    Join Date
    Jun 2009
    Posts
    215

    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
    donato is offline Senior Member
    Join Date
    Jun 2009
    Posts
    215

    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
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    Erm...

    That's what it does!

  9. #9
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    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
    donato is offline Senior Member
    Join Date
    Jun 2009
    Posts
    215

    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!

  11. #11
    donato is offline Senior Member
    Join Date
    Jun 2009
    Posts
    215

    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
    I'm trying here, but I am having a hard time...

  12. #12
    donato is offline Senior Member
    Join Date
    Jun 2009
    Posts
    215

    Default

    I tried this, but it doesn't work. I think because it is a dropdown and not a regular hyperlink...

    Code:
    			<xsl:template name="DepartmentDropDown">
    				<select>
    					<option value="Select">View All</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, '')}">
    							<a href="{aspdnsf:EntityLink(EntityID, SEName, $EntityName, 0, '')}">
    								<xsl:value-of select="$scName" disable-output-escaping="yes"/>
    							</a>
    						</option>
    					</xsl:for-each>
    				</select>
    			</xsl:template>

  13. #13
    donato is offline Senior Member
    Join Date
    Jun 2009
    Posts
    215

    Default Anyone?

    Does anyone know how to add the link to each dropdown item dynamically? Sorry... but I am not very familiar with this at all.

  14. #14
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    Sorry Mate - I have been (& still am) ill in bed.

    The second article I linked to has it all for you...

    I haven't tested it - but this should work :-


    C#/VB.NET Code:
                <xsl:template name="BFG-DropDown"
    <
    form name="jump1">
    <
    select name="myjumpbox"
     
    OnChange="location.href=jump1.myjumpbox.options[selectedIndex].value">
    <
    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>
    </
    form>
                </
    xsl:template


    TTFN

    BFG