I am trying to get a count of the number of nodes who's media field (id) pointed to media are of a certain type. Basically, I have a number of adverts which can either have flash, or images assocated with them. I need to know how many flash adverts there are.
Basically I am trying to pipe the output into umbraco.library:GetMedia so I can then get the media associated and check its local-name to see if it is "Flash" or "Image"
Ideally, I want this in one line, but have no idea how to do it.
I tried to do a loop and was going to increment a count, but can't do that either.
that doesnt output the number you would expect? could you output an xsl:copy-of the contents of $mediaItems[umbraco.library:GetMedia(.)/umbracoExtension= 'flash'] ?
L
ps i used umbracoType when it should have been umbracoExtension
Which is excluding the one node I want to count. I think you're missing how I've defined the Flash media type in Umbraco, unless you need it to be different to how it is now - it doesn't have an extension property (I think)
How are the flash media types defined? i.e. what is the property on the media node?
it seems that the one node you want to count doesnt have an umbracoExtension property but if we replace that for the property you are expecting we should be in business?
Death by XSLT - List nodes from another list
I am trying to get a count of the number of nodes who's media field (id) pointed to media are of a certain type. Basically, I have a number of adverts which can either have flash, or images assocated with them. I need to know how many flash adverts there are.
<xsl:variable name="source" select="umbraco.library:GetXmlNodeById(???)/*"/>
<xsl:variable name="mediaItems" select="$source/promoMedia" />
<xsl:for-each select="$mediaItems">
<xsl:copy-of select="." />
</xsl:for-each>
outputs
<promoMedia>1083</promoMedia>
<promoMedia>1173</promoMedia>
<promoMedia>1174</promoMedia>
<promoMedia>1175</promoMedia>
Basically I am trying to pipe the output into umbraco.library:GetMedia so I can then get the media associated and check its local-name to see if it is "Flash" or "Image"
Ideally, I want this in one line, but have no idea how to do it.
I tried to do a loop and was going to increment a count, but can't do that either.
Please help!
Hi Adrian
I think i understand what you are aiming for
Does the above work?
L
I don't see how as to get on one line, I'd need to put a list of items into the GetMedia call, but it ends up only operating on the first one.
Hmm thats strange so if your code is:
<xsl:variable name="source" select="umbraco.library:GetXmlNodeById(???)/*"/>
<xsl:variable name="mediaItems" select="$source/promoMedia" />
that doesnt output the number you would expect?
could you output an xsl:copy-of the contents of $mediaItems[umbraco.library:GetMedia(.)/umbracoExtension= 'flash'] ?
L
ps i used umbracoType when it should have been umbracoExtension
After a bit of adjusting so it doesn't error
<xsl:value-of select="count($mediaItems[umbraco.library:GetMedia(.,0)/umbracoExtension='Flash'])"/>
Gives 0 when it should give 1
hmm so what does:
<xsl:copy-of select="$mediaItems[umbraco.library:GetMedia(.,0)/umbracoExtension!='']"/>
output?
L
<promoMedia>1083</promoMedia>
<promoMedia>1173</promoMedia>
<promoMedia>1174</promoMedia>
<promoMedia>1175</promoMedia>
Which is excluding the one node I want to count. I think you're missing how I've defined the Flash media type in Umbraco, unless you need it to be different to how it is now - it doesn't have an extension property (I think)
Hi Adrian,
Okay well thats a start at least :)
How are the flash media types defined? i.e. what is the property on the media node?
it seems that the one node you want to count doesnt have an umbracoExtension property but if we replace that for the property you are expecting we should be in business?
L
is working on a reply...