I feel sure this should be easy, but I seem to have been going round in cirlces this morning!!
I am trying to create a XSLT that will produce a directory of links to Media Library items, starting from a given point. I have a document with a Media Picker on it to specify the starting point.
I would like the XSLT to read down through the hierarchy and produce links to the next level down if it exists, or links to the documents (currently all PDFs).
Any suggestions and / or pointers would be most welcome!
See the attached xslt file for a big step in the right direction. It could be cleaned up a lot and it currently relies on a media picker on the page to select a download folder, but it could be easily adapted to use macro parameters.
Sorry I don't have much time to explain further! These macros will create a nice list of documents with tags and file descriptions, filesize indicator and a an option to limit the list by tags. It's probably a bit of overkill but a good start nonetheless
<xsl:variable name="mediaFolder" select="umbraco.library:GetMedia($currentPage/data [@alias='documentMediaFolder'], 'true')" /> <!-- Is our folder a protected folder? If so, use Dirks PM tags -->
public XmlDocument DistinctValues(String commaList) {
string[] arr = commaList.Split(','); var distinctCount = new ArrayList(arr.Length); var distinctNames = new ArrayList(arr.Length);
foreach(string str in arr) { if(string.IsNullOrEmpty(str)) { continue; } var index = distinctNames.IndexOf(str); if (index >= 0) { var currentCount = (int)distinctCount[index]; distinctCount[index] = currentCount + 1; } else { distinctNames.Add(str); distinctCount.Add(1); } }
var outPut = ""; for (var i = 0; i < distinctNames.Count; i++) { var name = distinctNames[i]; var count = distinctCount[i]; outPut += "<value count='" + count + "'>" + name + "</value>"; }
var xml = new XmlDocument(); xml.LoadXml("<values>" + outPut + "</values>"); return xml; } ]]>
Create a directory list of media items
I feel sure this should be easy, but I seem to have been going round in cirlces this morning!!
I am trying to create a XSLT that will produce a directory of links to Media Library items, starting from a given point. I have a document with a Media Picker on it to specify the starting point.
I would like the XSLT to read down through the hierarchy and produce links to the next level down if it exists, or links to the documents (currently all PDFs).
Any suggestions and / or pointers would be most welcome!
Hi Gordon,
Can use below for-each loop to get you started
(Be aware though that it's querying the db quite heavily for each media item...)
Also have a look at cultiv's media caching package (can be found in the project section)
Cheers,
/Dirk
See the attached xslt file for a big step in the right direction. It could be cleaned up a lot and it currently relies on a media picker on the page to select a download folder, but it could be easily adapted to use macro parameters.
Sorry I don't have much time to explain further! These macros will create a nice list of documents with tags and file descriptions, filesize indicator and a an option to limit the list by tags. It's probably a bit of overkill but a good start nonetheless
Dan
documentList.xslt
documentListTags.xslt
Oops, should have added that it also uses Dirks protected media package, but this can be ripped out easily.
is working on a reply...