August 15, 2006
Jonathan kindly asked me how to extend/change the MultiplePagePickerViaSource, he wanted everything the same way, except media files instead of pages listed.
After some mailing with Jonathan, I thought to myself "it should take longer than 3 minutes to do that", and it actually didn't took longer than 3 minutes of coding :-)
Download (All files needed to use
MultipleMediaPickerViaSource in umbraco) 12 KB
Download source (Visual Studio 2003 project) 38
KB
If you are succeeded with installing the MultipleMediaPickerViaSource, then please make a comment on this blog post
In short the MultipleMediaPickerViaSource is a Data Type where you can select multiple files of a given media folder, you can also sort the selected files.
There are many ways of using the MultipleMediaPickerViaSource in umbraco, Jonathan needed a way to select a unlimited number of files to attach a case.
Install
Download (Link is in the top of this post).
Copy the two folders to your site.
How to use
Now you should be able to setup a new Data Type to use
CPalm.MultipleMediaPickerViaSource in the Developer section of
umbraco.
When you are using the CPalm.MultipleMediaPickerViaSource Data
Type in a Document Type is it important to tell the Data Type where
to pickup child's (Files).
You are doing this by using the field "Description" on the
property, you should write the ID of the mother (Media folder) of
the child's you want to get listed.
Example xslt using it
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
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"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable
name="mediaIdArray"
select="umbraco.library:Split($currentPage/data [@alias = 'selectedFiles'], ',')" />
<xsl:for-each select="$mediaIdArray/value">
<xsl:if test="string-length(.) > 0">
<xsl:variable name="media" select="umbraco.library:GetMedia(., false())" />
<a href="{$media/data[@alias = 'umbracoFile']}">
<xsl:value-of select="$media/@nodeName" />
(<xsl:value-of select="$media/data[@alias = 'umbracoBytes']" /> bytes)
</a><br />
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Web.Config
You can set some settings in the web.config if you want to - no
need to
<!--
If your wan't to place the javascript in another location
(if you use a virtual dir)
-->
<add
key="MultipleMediaPickerViaSource_JavascriptSrc"
value="/YouScriptFolder/MultipleMediaPickerViaSource.js"
/>
<!--
You could skip the IO file check if you wan't
-->
<add
key="MultipleMediaPickerViaSource_Skip_System.IO.File.Exists_Check"
value="true"
/>
Final notes
Yes, it only took 3 minutes to make this data type since
i could base it on MultiplePagePickerViaSource
5% on actually coding (the funny part)
95% of the time spent on this project was used on documentation,
screenshot, preparing code for download, writing blog post etc.