Copied to clipboard

Flag this post as spam?

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


  • Sri Harsha 8 posts 38 karma points
    Oct 25, 2013 @ 07:15
    Sri Harsha
    0

    Filtering nodes in Umbraco uComponents Checkbox Tree

    The umbraco website I'm working on has the below structure.

    Categories
        Filters
        Batteries
        Brakes
    Products
        prod 1
        prod 2
        prod 3
    Package Sizes
        Filters
            5 pack
            10 pack
            20 pack
        Batteries
            6 pack
            20 pack

    Categories use the category doctype, products the product doctype and package sizes, the package size doctype. The product doctype has a field(ultimate picker) that populates categories, so each product will be related to a category. Similarly, the package sizes also have a field that relates them to categories.

    Now, each product has a field called 'package size' which ideally should be a checkbox list and should have the sizes specific to that category. I tried using the 'checkbox tree' datatype in uComponents to list the package sizes but this lists all the package sizes, not the ones specific to this product. It currently looks like this.

    What I need is, if the product belongs to category called 'oils', then the package size should only display the nodes from 'oils'.

    I would like to know If there is any xPath expression that can do this, something similar to below. Or any other suggestions are appreciated. 

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Oct 25, 2013 @ 10:57
    Hendy Racher
    0

    Hi Sri,

    Yes it should be possible, as the token $currentPage can be used within the XPath Filter expression.

    If the desired list of checkboxes on a product to select a pack size is flat, then perhaps the built-in XPath CheckBoxList would be a more appropirate datatype ? (It's XPath configuration behaves in the same way)

    Are all the nodes within the PackageSizes tree of the same type ? is it just the top level Oils / Filters / Batteries .... nodes that have been tagged with a category, or has every package size been tagged ? can a product have more than one category ?

     

     

  • Sri Harsha 8 posts 38 karma points
    Oct 26, 2013 @ 15:58
    Sri Harsha
    0

    Hi Hendy,

    Thanks for the response. All the package size categories (oils, batteries...) has a doctype 'packageSizeCategory' and these are tagged with a category. The descendants of these package size categories have a common doctype called 'packageSize'. A product can have more than one category but if that is going to complicate things, I'll leave it for now and just assign a single category to a product.

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Oct 29, 2013 @ 12:04
    Hendy Racher
    1

    Hi Sri,

    Here's an XPath expression that can be used with the XPath CheckBoxList data-type on a product to render a collection of associated package sizes:

    //PackageSizeCategory[category=$currentPage/category]/*

     

    Both the PackageSizeCategory and Product document-types use an XPath DropDownList data-type to select a category (XPath: //Category), where the alias for each is category

    HTH,

    Hendy

Please Sign in or register to post replies

Write your reply to:

Draft