Copied to clipboard

Flag this post as spam?

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


  • Dan 1250 posts 3747 karma points admin c-trib
    Oct 24, 2012 @ 14:36
    Dan
    0

    Get all nodes of multi-node tree picker parent

    Hi,

    Here's the kind of structure I'm working with:

    - Categories
    - - Category 1
    - - - Sub-category 1
    - - - Sub-category 2
    - - - Sub-category 3
    - - Category 2
    - - - Sub-category 4
    - - - Sub-category 5
    - - - Sub-category 6
    ...etc

    - Products
    - - Product 1
    - - Product 2
    - - Product 3
    ...etc

    Each product is categorised using the multi-node tree picker data type, using sub-categories as the permitted MNTP nodes.  So, for example, 'Product 1' belongs to 'Sub-category 2' and 'Sub-category 3'.

    However, on the website there is a category-level page (http://www.example.com/categories/category-1/) which needs to show all products belonging to any sub-category in this category.

    Would any of the XSLT gurus be able to suggest an XPath query to do this?  It's beyond me!

    (I realise it would be simple if the MNTP was set such that the products were tagged by both category and sub-category but that's a lot of extra work at this stage [1000s of products] and would rely on the customer remembering to tag both category and sub-category, which doesn't seem like the best idea.)

    Thanks for any points folks...

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Oct 24, 2012 @ 14:47
    Chriztian Steinmeier
    1

    Hi Dan,

    Off the top of my head, something like this:

    $siteRoot//Product[subcategory//nodeId = $currentPage/SubCategory/@id]

    $siteRoot being something like $currentPage/ancestor-or-self::*[@level = 1]

    Product and SubCategory being DocumentType aliases and subcategory the alias of the MNTP picker property

    /Chriztian

  • Dan 1250 posts 3747 karma points admin c-trib
    Oct 24, 2012 @ 15:43
    Dan
    0

    This is one of those times when XSLT/XPath proves to be so powerful - thanks Chriztian, that's brilliant, works perfectly!

  • 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