Get all documents of a document type with criteria
I'm having a bit of trouble, hope you guys can spot my error. I am trying to loop through all of the documents with a documenttype of "book". I want to see only the books that are set as tip. The tip checkbox is called "isTip". So I thought I'd try this:
This returns no result :-( However, when I leave off the "isTip" criteria in the for-each, I get a nice list of books and 1's and 0's for the tips checkboxes:
Get all documents of a document type with criteria
I'm having a bit of trouble, hope you guys can spot my error. I am trying to loop through all of the documents with a documenttype of "book". I want to see only the books that are set as tip. The tip checkbox is called "isTip". So I thought I'd try this:
<xsl:for-each select="umbraco.library:GetXmlAll()//node [@nodeTypeAlias='Book']/node [string(data [@alias='isTip']) = 1]"> <xsl:value-of select="./@nodeName"/> - <xsl:value-of select="string(data [@alias='isTip'])" /> <br /> </xsl:for-each>
This returns no result :-(
However, when I leave off the "isTip" criteria in the for-each, I get a nice list of books and 1's and 0's for the tips checkboxes:
<xsl:for-each select="umbraco.library:GetXmlAll()//node [@nodeTypeAlias='Panorama']"> <xsl:value-of select="./@nodeName"/> - <xsl:value-of select="string(data [@alias='isTip'])" /> <br /> </xsl:for-each>
So, what am I doing wrong in that extra criterion?
Grrr, no "edit" button. The 'Panorama' in the second sample should read 'Book' of course.
I think this should do the trick:
HTH,
Peter
Yeah, I tried leaving off the "node" part, but the XSLT parser didn't like that all too much.
Maybe the relevant difference in Peters code is the data type in the second condition?
In your original code you are converting isTip to string, but the comparing it to an integer (without ').
Yours
[string(data [@alias='isTip']) = 1]
Peters
[string(data [@alias='isTip']) = '1']
What about this:
<xsl:for-each select="umbraco.library:GetXmlAll()//node [(@nodeTypeAlias = 'Book') and (data [@alias='isTip'] = '1')]">
Hm, last one was close, this should work:
<xsl:for-each select="umbraco.library:GetXmlAll()//node[@nodeTypeAlias = 'Book' and string(data[@alias = 'isTip']) = '1']">
Thanks Daniel, I did correct this :-)
It's just not working, second suggestion doesn't work either Peter.
Aah, thanks Peter! I get it now, the expression was not properly surrounded by brackets. Cool, learn something new every day!
is working on a reply...