is there a way to check to which node does a specific file inside de media folder belongs to? :-k
e.g.:
I have a file: /media/217/somepdffile.pdf and I want to check which Node is using this file (as File Upload datatype)
I think that the link is the other way, i.e. the nodes will store the media id if they are using it, rather than vice versa. This way the media item is reusable across the site.
A .NET control to do this would not be efficient, best to do it using XSLT. You would need a recursive call to return all nodes whose named attribute stored the value of the id of your media item (hover over the item in the media section to get the media item id).
Okay this works. If you need this as a general purpose solution you may wish to change the variables into macro parameters. Note that this code uses the home page node of your site as the "parent" node of the recursive call, so set the homeNodeId variable value to the id of the parent node of your site content.
Also note that I'm assuming that the media item is being used in the "image" attribute of the content nodes - if it could be used for a different attribute, then you'll need to alter the xslt accordingly.
Hope that helps!
Edit: original post had "mpu" instead of "image" as the attribute name. Updated the xslt.
Media Folder and Content relationship
Hi,
is there a way to check to which node does a specific file inside de media folder belongs to? :-k
e.g.:
I have a file: /media/217/somepdffile.pdf and I want to check which Node is using this file (as File Upload datatype)
thanks!
Pedro
Hi pvassalo,
I think that the link is the other way, i.e. the nodes will store the media id if they are using it, rather than vice versa. This way the media item is reusable across the site.
A .NET control to do this would not be efficient, best to do it using XSLT. You would need a recursive call to return all nodes whose named attribute stored the value of the id of your media item (hover over the item in the media section to get the media item id).
Following this post on xslt recursion, you could try something like this:
[code]
select="$items/descendant-or-self::node[data[@alias='IMAGEATTRIBUTE'] = $YOURMEDIAID]"/>
[/code]
I haven't tested this - how is your XSLT? :) I'll try and get a full xslt file that works...
David
Okay this works. If you need this as a general purpose solution you may wish to change the variables into macro parameters. Note that this code uses the home page node of your site as the "parent" node of the recursive call, so set the homeNodeId variable value to the id of the parent node of your site content.
Also note that I'm assuming that the media item is being used in the "image" attribute of the content nodes - if it could be used for a different attribute, then you'll need to alter the xslt accordingly.
Hope that helps!
Edit: original post had "mpu" instead of "image" as the attribute name. Updated the xslt.
[code]
]>
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
[/code]
is working on a reply...