Listing available files for download, in specific document type.
For example I have a document type (page), which could have 1 to 5 (pdf or doc) files associated with it, and I want to make a "Download" section to list all these files.
I'm thinking of
1) document property as mediapicker datatype, but that would mean I must create up to 5 properties
2) listing all media files available in specific media folder (associated with page)
yep, code examples are always usefull to learn and reuse. Experimenting now with "TreeMultiPicker", have you some xlst excerpt how do I list this tree files?
Create two documenttypes - 1. DownloadArea and 2. DownloadItem. Create the DownloadArea in your content and create the DownloadItems below the Download Area:
DownloadArea
-DownloadItem
-DownloadItem
-DownloadItem
DownloadItem should have an UploadField property.
Create an xslt which lists all of the DownloadItems below the DownloadArea.
You can also add new fields such as description ertc to files stored in the media library (check "media types" in the settings areas) and access them using GetMedia in the same way. Combined with a multiple upload datatype it makes media management easier when kept in the media tree.
Can anyone give a help on how to add a small gif "file" icon to any listed documents? Would be ace if this was dependant on the file type (i.e. .pdf .doc .mp3 etc) so that a different gif gets displayed according to the file being listed.
I guess it can be done with XSLT but I'm very much a newb in that area.
Then all you have to do is add rules in the css to match up your favourite icon with the right class. You can also do this with attribute selectors in css but they're not universally supported, so the above method is safer.
I am a noobie and I'm not sure if it is correct ettiquette to come in on the end of the thread. I am having difficulties with Dandrayne's excellent looking XSLT and was wondering if anyone could give me a tip. I'm guessing it has something to do with 4.5 doing XSLT a bit different maybe.
My full XSLT file looks like below (it's a copy of Dandrayne's with the different alias);
System.OverflowException: Value was either too large or too small for an
Int32. at System.Convert.ToInt32(Double value) at
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider
provider) at
System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType
xmlType, Object value, Type destinationType) at
System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name,
String namespaceUri, IList`1[] args) at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at
Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at
System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver
dataSources, XsltArgumentList argumentList, XmlWriter writer) at
System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input,
XsltArgumentList arguments, TextWriter results) at
umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String
oldName, String fileContents, Boolean ignoreDebugging)
If anyone had any thoughts on what might be causing that, I'd be very appreciative.
I'm new here too, so this may not be all correct, but I've encountered similar problems, and this is what I've discovered:
The 4.5 and 4.5.1 versions changed the xml and require different xslt.
Try changing from this: /data [@alias='umbracoFile']
to this: /umbracoFile
Also, since you are using umbraco.library:GetMedia the document for which this xslt is executing has to have a property defined that has the type Media Picker. If there is not a Media Picker property defined for your document then you will see that xslt error.
I have ended up with the following which is working in 4.5.1. It works off a media picker that selects a folder. I still have to make it look pretty but it will display all the files in that folder.
I'm using umbraco 4.5.2 on w.server 2003 r2 with .net 3.5,
i'm trying your solution but when i save the xslt file return me an error : Error occured
System.OverflowException: Valore troppo grande o troppo piccolo per un Int32.
in System.Convert.ToInt32(Double value)
in System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
in System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
in System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
in System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
in (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
in Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
in Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
in System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
XmlResolver dataSources, XsltArgumentList argumentList,
XmlSequenceWriter results)
in System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter
writer, Boolean closeWriter)
in System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable
contextDocument, XmlResolver dataSources, XsltArgumentList argumentList,
XmlWriter results)
in System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable
contextDocument, XmlResolver dataSources, XsltArgumentList argumentList,
TextWriter results)
in System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
in umbraco.presentation.webservices.codeEditorSave.SaveXslt(String
fileName, String oldName, String fileContents, Boolean ignoreDebugging)
the mediapicker alias in the document type is right :(
best practice for listing download files
Hi,
What is best practice, how do you do:
Listing available files for download, in specific document type.
For example I have a document type (page), which could have 1 to 5 (pdf or doc) files associated with it, and I want to make a "Download" section to list all these files.
I'm thinking of
1) document property as mediapicker datatype, but that would mean I must create up to 5 properties
2) listing all media files available in specific media folder (associated with page)
What are other options?
Marius
You could:
I tend to go with option 2. Post back if you need a code sample for one of these options
Dan
Thanks, dandrayne,
yep, code examples are always usefull to learn and reuse. Experimenting now with "TreeMultiPicker", have you some xlst excerpt how do I list this tree files?
Ok - the following samples should work but are untested
Dan
You could also use another option:
Create two documenttypes - 1. DownloadArea and 2. DownloadItem. Create the DownloadArea in your content and create the DownloadItems below the Download Area:
DownloadArea
-DownloadItem
-DownloadItem
-DownloadItem
DownloadItem should have an UploadField property.
Create an xslt which lists all of the DownloadItems below the DownloadArea.
Yes, first example with only "Lefteris" mode work correctly.
Big thanks, Dandrayne
...That way you could also add specific download image, description etc. to each download item. :)
Thanks, Berntsen,
that's an option, yes,
Though I like Dandrayne solution more, because it's more flexible I think.
Oh, man, clicked by mistake on Berntsen post as solved, sorry Dan..., I liked your tip.
Heh, no problem!
You can also add new fields such as description ertc to files stored in the media library (check "media types" in the settings areas) and access them using GetMedia in the same way. Combined with a multiple upload datatype it makes media management easier when kept in the media tree.
Dan
Hello - this is a really helpful thread.
Can anyone give a help on how to add a small gif "file" icon to any listed documents? Would be ace if this was dependant on the file type (i.e. .pdf .doc .mp3 etc) so that a different gif gets displayed according to the file being listed.
I guess it can be done with XSLT but I'm very much a newb in that area.
Thanks for any help offered,
Barney
@Barney
How i did this was to add a class to the list item (you could also do the link or whatever) of the file extension
using the 2nd method (media picker to pick folder)
Then all you have to do is add rules in the css to match up your favourite icon with the right class. You can also do this with attribute selectors in css but they're not universally supported, so the above method is safer.
Dan
Thanks Dan, you're a star. I'll give this a go... very much appreciated.
any thoughts on a download counter? had a client ask me about it today and really had no idea where to start?
Hi Bob,
I was in the same position a little over a month ago, and ended up creating some custom code for this.
Here is the originale post with my solution in the second last post
Hope it helps.
Frederik
Hello there,
I am a noobie and I'm not sure if it is correct ettiquette to come in on the end of the thread. I am having difficulties with Dandrayne's excellent looking XSLT and was wondering if anyone could give me a tip. I'm guessing it has something to do with 4.5 doing XSLT a bit different maybe.
My full XSLT file looks like below (it's a copy of Dandrayne's with the different alias);
But it gives me the following error;
If anyone had any thoughts on what might be causing that, I'd be very appreciative.
Thank you
Nacho,
I'm new here too, so this may not be all correct, but I've encountered similar problems, and this is what I've discovered:
The 4.5 and 4.5.1 versions changed the xml and require different xslt.
Try changing from this: /data [@alias='umbracoFile']
to this: /umbracoFile
Also, since you are using umbraco.library:GetMedia the document for which this xslt is executing has to have a property defined that has the type Media Picker. If there is not a Media Picker property defined for your document then you will see that xslt error.
--steve
Thanks Steve.
A lot to learn isn't there :)
I have ended up with the following which is working in 4.5.1. It works off a media picker that selects a folder. I still have to make it look pretty but it will display all the files in that folder.
Hopefully this will help the next noobie to come a long too.
Hello Dan,
I'm using umbraco 4.5.2 on w.server 2003 r2 with .net 3.5,
i'm trying your solution but when i save the xslt file return me an error : Error occured
System.OverflowException: Valore troppo grande o troppo piccolo per un Int32.
in System.Convert.ToInt32(Double value)
in System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
in System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
in System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
in System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
in (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
in Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
in Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
in System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
in System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
in System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
in System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results)
in System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
in umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
the mediapicker alias in the document type is right :(
cheers,
Fabio
is working on a reply...