Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Client needs media to be searched. I know XSLT searches the content properties, but I need it to support searching the media properties.
Media is accessed differently than content, but is there a bit of XSLT that I can add to the XSLT file to check if the starting node is a media item and search accordingly?
I was hoping to do this using the existing XSLTSearch without much modification.
The result should be a direct link to the media file (i.e. umbracoFile property)
Thanks for any insight.
You basically have to modify the possibleNodes variable. I've done this a couple of times now and it works a treat, however keep an eye on performance if that is an issue. It goes something like this:
- create a custom variable with a 'root' element
- add as many nodes to it as you need, using copy-of
- generate a proper node set, replacing the existing possibleNodes variable
<xsl:if test="is current node a media item?">
<xsl:copy-of select="current()" />
<xsl:if test="another condition">
<!-- add as many nodes as you like -->
<xsl:variable name="possibleNodes" select="msxml:node-set($possibleNodesRaw)/container/*[@isDoc]" />
The search script will then use these nodes for all search operations.
Hope that helps,
I have followed the instructions above but get no results when searching. The search searches the correct media nodes and the parameters should be correct, but still no results. Did a copy-of to see the raw data of my possibleNodes variable, and this returns the following for each media item:
<Image id="1056" version="b6b7dce1-9f23-412a-b2fc-5eaf7912cd1b" parentID="1055" level="4" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2011-04-05T13:43:40" updateDate="2011-04-05T13:43:41" nodeName="random image" urlName="randomimage" writerName="admin" nodeTypeAlias="Image" path="-1,1053,1054,1055,1056"><umbracoFile>/media/35/ernst.jpg</umbracoFile><imgDescription>Random bilde for testing av galleri</imgDescription><imgTags>Ernst,Eliah</imgTags><umbracoWidth>453</umbracoWidth><umbracoHeight>604</umbracoHeight><umbracoBytes>60518</umbracoBytes><umbracoExtension>jpg</umbracoExtension></Image>
The properties im searching is @nodeName,imgTags,imgDescription.
Any idea what I am missing? Posting the only change I have made to the xslt:
<xsl:variable name="possibleNodesRaw"> <container> <xsl:for-each select="umbraco.library:GetMedia(1053, '0')/descendant::* [@nodeTypeAlias='Image']"> <xsl:copy-of select="current()" /> </xsl:for-each> </container> </xsl:variable> <!-- reduce the number of nodes for applying all the functions in the next step --> <xsl:variable name="possibleNodes" select="msxml:node-set($possibleNodesRaw)/container/* " />
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted