I'm preety sure this question of mine is one of the first lessons of Umbraco 101 but I've been too long in some other aspects of it that I really can't remeber this...
I'd like to template umbraco's media files per filetype (file extension). Is it possible (so that every PDF file opens in the same template and not open the file itself - is this the case of passing media url as query param to a template)? Any suggestions please?! Examples would be greatly appreciated.
Seems that I'm not having a mental block but I'm dumb about XSLT (got any literature to recommend:)...I'm not sure how to use this...I think it should be used somewhat like the RSSFeed XSLT that was written in CWS by Warren but I'm not sure how, since I keep getting errors all the time I try to save it.
however it won't save without errors (though I'm guessing the errors might not be designtime but runtime which I unfortunatelly can't determine due to the lack of XSLT skills:)...
As for the approach I had in my mind...I thought something like not having to make a document type instance each time I make/upload a media file...you know the document that would contain a media picker that would hold the reference to the media (since the media items on my site might grow and grow and grow in numbers)...I thought something like making a single / or multiple / but still few document instances on my site that would be media containers of some sort...like maybe passing a relative path to the media that should be displayed in the query string and then have that document (or scripts XSTL/JS within it's template) determine what to do to display it properly (like do the flexpaper for pdf, or fwplayer for flv etc.)
Doable? Thanks again...
p.s.
Sorry for the delay in my reply I'm still trying to fix that WLW F2 properties button being disabled for my content channel...must of tried almost everything...but I sure it's something trivial that I just don't see :(((
Forgot the error...I think it's runtime...but I don't know how to debug it (is there really any good literature to read on the subject of XSLT writing and debugging it in Umbraco out there):
System.OverflowException: Value was either too large or too small for an Int32. at System.Convert.ToInt32(Double value) at System.Double.System.IConvertible.ToInt32(IFormatProvider provider) 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 Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter) at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results) at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results) 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)
call to GetMedia() will result in this error specified in your previous post as it won't have any value until "runtime". Best practise is to put an xsl:if statement around the apply-templates call
Template media files
I'm preety sure this question of mine is one of the first lessons of Umbraco 101 but I've been too long in some other aspects of it that I really can't remeber this...
I'd like to template umbraco's media files per filetype (file extension). Is it possible (so that every PDF file opens in the same template and not open the file itself - is this the case of passing media url as query param to a template)? Any suggestions please?! Examples would be greatly appreciated.
Cheers, stc.
Hi stc, do you mean in XSLT? If so, then I use this as an include XSLT:
Then I can apply the templates using:
You'll need to tweak the XPath accordingly, but it should work nicely!
Cheers, Lee.
Hi Lee,
Seems that I'm not having a mental block but I'm dumb about XSLT (got any literature to recommend:)...I'm not sure how to use this...I think it should be used somewhat like the RSSFeed XSLT that was written in CWS by Warren but I'm not sure how, since I keep getting errors all the time I try to save it.
This is what I wrote so far:
however it won't save without errors (though I'm guessing the errors might not be designtime but runtime which I unfortunatelly can't determine due to the lack of XSLT skills:)...
As for the approach I had in my mind...I thought something like not having to make a document type instance each time I make/upload a media file...you know the document that would contain a media picker that would hold the reference to the media (since the media items on my site might grow and grow and grow in numbers)...I thought something like making a single / or multiple / but still few document instances on my site that would be media containers of some sort...like maybe passing a relative path to the media that should be displayed in the query string and then have that document (or scripts XSTL/JS within it's template) determine what to do to display it properly (like do the flexpaper for pdf, or fwplayer for flv etc.)
Doable? Thanks again...
p.s.
Sorry for the delay in my reply I'm still trying to fix that WLW F2 properties button being disabled for my content channel...must of tried almost everything...but I sure it's something trivial that I just don't see :(((
Forgot the error...I think it's runtime...but I don't know how to debug it (is there really any good literature to read on the subject of XSLT writing and debugging it in Umbraco out there):
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
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 Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer, Boolean closeWriter)
at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument, XmlResolver dataSources, XsltArgumentList argumentList, TextWriter results)
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)
yep, it's a quite common mistake often made... even by more xperienced xslt gurus.
call to GetMedia() will result in this error specified in your previous post as it won't have any value until "runtime". Best practise is to put an xsl:if statement around the apply-templates call
<xsl:if test="string($currentPage/data[@alias='media']) != ''"> <xsl:apply-templates select="umbraco.library:GetMedia($currentPage/data[@alias='media'], 1)Page, 1)" mode="media" /> </xsl:if>
Above snippet will prevent the error from being thrown. It's either that or check the 'Skip errors' box.
Hope this helps.
Regards,
/Dirk
is working on a reply...