Copied to clipboard

Flag this post as spam?

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


  • Mike Taylor 155 posts 353 karma points
    Jul 24, 2012 @ 20:25
    Mike Taylor
    0

    MNTP - can I use XPath filter to only enable nodes that are selected in another MNTP field somewhere?

     

    This works (hard-coded IDs):

    /* [name()='Country' and contains("1780,1779,1788,1588,1638,1724",@id)]


    But this doesn't (CSV list of IDs selected on another MNTP):

    /* [name()='Country' and contains(//Metadata/Countries/naRegion/text(),@id)]

     

    Is there any way I can use the nodes selected in one MNTP (field called "naRegion" on //Metadata/Countries node, stored as CSV) as the XPath filter on another MNTP field?

     

  • Kim Grandgagnage 63 posts 87 karma points
    Jul 26, 2012 @ 13:35
    Kim Grandgagnage
    0

    Hi,

    I have the same question! Hopefully someone knows the answer soon...

    grts,

    Kim

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jul 26, 2012 @ 16:08
    Lee Kelleher
    0

    Hi Mike,

    I *think* this has to do with context within the XPath itself.  When using the "//Metadata/Countries" inside the predicate it would be querying all descendants from the current node, not the root node.

    Given that I don't know the structure of your nodes, here's a sledge-hammer approach:

    /Country[@isDoc and contains($currentPage/ancestor::root/descendant::Metadata/Countries/naRegion, @id)]

    Can't remember which version of uComponents we introduced replacing the "$currentPage" param - I'm sure its been in there a while now.

    To explain the rest of the XPath... it will take the currentPage, go up the tree until it reaches the <root>, then back down until it finds all the <Metadata><Countries><naRegion> tags ... then checks if any of them contain the @id value.

    Good luck!

    Cheers, Lee.

  • Mike Taylor 155 posts 353 karma points
    Jul 26, 2012 @ 16:41
    Mike Taylor
    0

    Thanks Lee --- I think my problem is the $currentPage thing... this site is running Umbraco v4.7.1, and I think it barfs at the $currentPage parameter.

    M

  • Mike Taylor 155 posts 353 karma points
    Jul 26, 2012 @ 16:45
    Mike Taylor
    0

    Just checked - uComponents is v2.2 --- I'm a bit scared of upgrading though, in case it interferes with the datatypes I'm already using on 1,000+ nodes... (eek)

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jul 26, 2012 @ 16:47
    Lee Kelleher
    0

    Hi Mike,

    Just realised that we only added it to uComponents v4.0 (beta) (link to original feature request).

    Although it's still a beta, it's very stable - I've been using it on several client projects/websites with no issues - could be worth trying it out?

    Cheers, Lee.

  • Mike Taylor 155 posts 353 karma points
    Jul 26, 2012 @ 16:49
    Mike Taylor
    1

    Ooooh, that was my original feature request! (Had completely forgotten I'd done that!)

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jul 26, 2012 @ 16:53
    Lee Kelleher
    0

    For piece of mind... v2.2 was in such a long beta phase that people thought it was an official release (it never was), so to avoid confusion, we bumped the version number up to v3.0.

    The rest of the v3.x.x releases are generally bug fixes (we introduced a new XSLT extension, for CMS Users, hence the bump up to 3.1.x)

    As for v4.0 (currently beta), biggest changes are switch from .NET 3.5 to .NET 4.0 (which in turn supports Umbraco 4.6.1+) and change the "nodeFactory" references from "umbraco.presentation.nodeFactory" to the new "umbraco.NodeFactory".

    Generally speaking, I've tried to keep backwards-compatiablilty a top priority.

    Cheers, Lee.

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jul 26, 2012 @ 16:54
    Lee Kelleher
    0

    Just made the mental map between you and your CodePlex username :-)

  • Andrew Waegel 126 posts 126 karma points
    Aug 19, 2012 @ 05:21
    Andrew Waegel
    0

    Hello,

    I just upgraded to uComponents 4.0 on Umbraco 4.7.2, and it's my understanding that $currentPage should work in the xpath filter, but I'm having no luck.

    My filter looks like this:

    /* [contains(categories,$currentPage/listingCategory)]

    ...where categories is text field with multiple category names, and $currentPage/listingCategory is the category chosen for the current page.

    If I just use plain text in the filter, it works perfectly:

    /* [contains(categories,"My Great Category Name")]

    Should this be working, or am I barking up the proverbial wrong tree?

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Aug 20, 2012 @ 16:47
    Lee Kelleher
    0

    Hi Andrew,

    Do you know what value the "$currentPage/listingCategory" property has? Is it a string? (Sorry to sound obvious, but I have no idea what the value could be)

    Thanks, Lee.

  • Andrew Waegel 126 posts 126 karma points
    Aug 20, 2012 @ 23:52
    Andrew Waegel
    0

    Hi Lee, it's a string, as is 'categories'. A typical/hypothetical set of values:

    categories="cat1,cat2,cat3"

    listingCategory="cat2"

Please Sign in or register to post replies

Write your reply to:

Draft