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:variablename="filterProxy"> <filterid="6624"property="facultyDepartment"value="Department A"/> <filterid="3385"property="facultyDepartment"value="Department B"/> <!-- ETC. --> </xsl:variable>
<!-- Grab the filter that applies to the current page --> <xsl:variablename="facultyFilter"select="msxml:node-set($filterProxy)/filter[@id = $currentPage/@id]"/>
<!-- Grab the root node to do lookups under --> <xsl:variablename="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-ofselect="@nodeName"/> <!-- ETC. --> </p> </xsl:for-each>
At first I thought I just needed to include an OR statement like
<filterid="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 :
Department A
Department B
Department A and B combined
Does anyone know what might be causing the error and how I can resolve my issue? Thank you!
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:
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.
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 :)
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)
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.
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
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 :
Does anyone know what might be causing the error and how I can resolve my issue? Thank you!
I'm using v4.81
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
Hi Chriztian,
Thanks.. but I've been able to combine lists by simply doubling up on the nodeID like this,
It seems like:
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.
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 :)
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:
*anyone with any ideas why nodes with 2 options get eliminated from my filtered results?
Not sure why this didn't work for me before but it seems to now if I do this:
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:
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)
is working on a reply...