Copied to clipboard

Flag this post as spam?

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


  • FarmFreshCode 225 posts 422 karma points
    Jul 29, 2013 @ 20:23
    FarmFreshCode
    0

    Retrieve Items by Datatype Value WHEN 2 are present in XSLT

    I have built a directory of people. One of the docTypes is a series of checkboxes where the individual can check off all of the departments that they are involved in. The code below helps me to create department specific pages that list all of the people that have checked that 1 specific department.

    HOWEVER - people that have checked off 2 or more departments in the list DO NOT show up at all. This is where my problem is.

    <!-- Build an XML variable with all the filters available -->
    <xsl:variable name="filterProxy">
           
    <filter id="6624" property="facultyDepartment" value="Department A" />
           
    <filter id="3385" property="facultyDepartment" value="Department B" />
           
    <!-- ETC. -->
    </xsl:variable>

    <!-- Grab the filter that applies to the current page -->
    <xsl:variable name="facultyFilter" select="msxml:node-set($filterProxy)/filter[@id = $currentPage/@id]" />

    <!-- Grab the root node to do lookups under -->
    <xsl:variable name="rootNode" select="umbraco.library:GetXmlNodeById(6394)" />

    <!-- Filter the FacultyProfile nodes using the filter (or return all of them if no filter matched) -->
    <xsl:for-each
       
    select="$rootNode/FacultyProfile[*[name() = $facultyFilter/@property] = $facultyFilter/@value]
        | $rootNode/FacultyProfile[not($facultyFilter)]"
    >
       
    <p>
           
    <xsl:value-of select="@nodeName" />
           
    <!-- ETC. -->
       
    </p>
    </xsl:for-each>

    The above solution was provided by Chriztian Steinmeier 
    back on my orginial post

    At first I thought I just needed to include an OR statement like

    <filter id="6624" property="facultyDepartment" value="Department A -OR- Department B" />

    Granted I know that's not how to write it... but I don't think that will really solve it because anyone with more than 1 box checked isn't being shown at all anyway.

    I need to be able to generate a page with all people in :

    1. Department A
    2. Department B
    3. Department A and B combined

    Does anyone know what might be causing the error and how I can resolve my issue?  Thank you!

    I'm using v4.81

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 30, 2013 @ 21:05
    Chriztian Steinmeier
    0

    Hi - just a quick thought:

    This being checkboxes, I'm imagining that having both of them checked would put them both in the value of the property - so you may be able to do something as simple as this:

    <filter id="6624" property="facultyDepartment" value="Department A,Department B" />

    I.e., if it stores the values as CSV - that would indeed work. Maybe check the Umbraco XML for the nodes where Both are checked just to be sure...

    /Chriztian

  • FarmFreshCode 225 posts 422 karma points
    Jul 30, 2013 @ 21:29
    FarmFreshCode
    0

    Hi Chriztian,

    Thanks.. but I've been able to combine lists by simply doubling up on the nodeID like this,

    <filter id="6624" property="facultyDepartment" value="Department A" />
    <filter id="6624" property="facultyDepartment" value="Department B" />
    

    It seems like:

    <filter id="6624" property="facultyDepartment" value="Department A,Department B" />
    

    just comes up blank.

    Combining lists isn't so much of the issue... it's where I have an employee named "Mike"... and Mike has Department A and Department B checked off. He doesn't currently show up in a listing of department A OR department B at all.. So combining wouldn't resolve that.

    For some reason people with multiple boxes checked aren't being pulled at all.

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 31, 2013 @ 07:14
    Chriztian Steinmeier
    0

    Hi again,

    It's only a matter of knowing how multiple values are stored, so you need to check the Umbraco.config (in the App_Data folder) or maybe install the XMLDump package, and inspect the nodes where more than one category has been checked, to see how they're stored. Then we can tailor the XSLT to fetch them.

    /Chriztian

    PS: Doubling the ID's was pretty smart, actually - it only works because of the way XPath works with sets, but that's just great :)

  • FarmFreshCode 225 posts 422 karma points
    Jul 31, 2013 @ 14:06
    FarmFreshCode
    0

    Even a blind squirrel finds a nut from time to time. :) but thanks.

    I found the section in the Umbraco.config file and I see that it's written out like this:

    <facultyDepartment><![CDATA[Department A,Department B]]></facultyDepartment>
    
  • FarmFreshCode 225 posts 422 karma points
    Aug 05, 2013 @ 19:24
    FarmFreshCode
    0

    *anyone with any ideas why nodes with 2 options get eliminated from my filtered results?

  • FarmFreshCode 225 posts 422 karma points
    Aug 05, 2013 @ 19:44
    FarmFreshCode
    0

    Not sure why this didn't work for me before but it seems to now if I do this:

    <filter id="6624" property="facultyDepartment" value="Department A" />
    <filter id="6624" property="facultyDepartment" value="Department A,Department B" />
    <filter id="6624" property="facultyDepartment" value="Department A,Department C" />
    

    However this forces me to list any and ALL combination in advance which won't work as a long time solution.

    What I would prefer is a statement that says... "IF Department A is checked at ALL.. list it."

    My second choice would be to have something like a wildcard option:

    <filter id="6624" property="facultyDepartment" value="Department A" />
    <filter id="6624" property="facultyDepartment" value="Department A,*" />
    <filter id="6624" property="facultyDepartment" value="Department A,*,*" />
    

    Is there anything out there that would work like this? Telling it to list all nodes checked with Department A checked.. Or Department A AND anything else checked.

    **Note it's totally possible for a user to check 3 options (while rare, I still need to have a solution for that too)

Please Sign in or register to post replies

Write your reply to:

Draft