MultipleMediaPickerViaSource

August 15th, 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.

See the screenshots to get a better understanding

Setting up data type in umbraco
Screenshot: setting up data type in umbraco

Setting up the document type in umbraco
Screenshot: setting up the document type in umbraco

Selecting files on page
Screenshot: selecting files on page

Xslt inserted via a macro in the editor
Screenshot: Xslt macro inserted in the editor, could be in the template instead

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<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(.) &gt; 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

XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!--
	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.

Updated 2006-09-20, I have updated the xslt example with a if statement

 

Tags: Umbraco, Umbraco Extension

Comments

#1 - Michael Chung on August 17, 2006 13:24

I've installed the MultiplePagePickerViaSource successfully - it works great as my 'download file' selector. Slight problem with the case when there is nothing selected though - I get this XSLT error:

System.Xml.Xsl.XsltException: Function 'umbraco.library:GetMedia()' has failed. ---> System.ArgumentException: Cannot widen from target type to primitive type.

I understand this is quite common when using GetMedia, I'm just trying to figure out how to use the xslt:if statement to fix it up.

#2 - Christian Palm on September 20, 2006 13:00

#1 I have updated the xslt example with the IF statement

#3 - Jesper on June 26, 2007 18:16

Hi Christian,

I used this to build a couple of memberPickers ... but I'm wondering about this "addSaveHandler". What is it .. and where is it defined? I'm trying to use the datatypes with autoform .. without any luck .. because of this missing "addSaveHandler" ...

Got a clue?

Kindly,

Jesper

#4 - Ian George on August 14, 2007 15:26

Hi I've used this on a client's site and for the most part it's great. Unfortunately when media that is selected is deleted it leaves blank list items on the selected side that can't be removed. I've hacked the front end of the site to ignore the blank entries for now but is there a more elegant way to handle this?

#5 - Alec on November 20, 2007 20:18

We use this tool however have found a bug.. We have a seit in Korian and the issue is you can add nodes but cannot remove them. Any ideas?

#6 - Rodger on September 16, 2008 15:05

Works fine :)

#7 - Tony on September 29, 2008 16:01

Strange. I've used the MultiContentPicker before and it seems to be working fine. Now when I tried this one the CPalm.MultipleMediaPickerViaSource refuse to show up with other Data Types when I try creating new Data Type.
My CPalm.MultiplePagePickerViaSource showd up after I followed instructions ni installation textfile.

Any suggestions???

Regards, Tony H

#8 - buy viagra on December 06, 2009 23:31

Works fine :)

#9 - Best mp3 Music on December 07, 2009 10:47

Works fine :)
Best regards,

#10 - Dota allstars on December 17, 2009 11:20

rly nice work!

#11 - Buy Viagra Sydney on January 08, 2010 15:04

its work. exelent

#12 - Rent a Car in Ukraine on February 11st, 2010 17:18

Hire a Car in Ukraine

#13 - Down comforter sets on March 17, 2010 18:51

Well well folks, I think you should change comment system.

#14 - medical assistant your online on March 21st, 2010 20:16

this is a link pomoyka

#15 - laptop battery manufacturer on May 21st, 2010 11:10

n 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.

#16 - RAR Downloads on May 24, 2010 12:41

Nice share, Thanks

#17 - VideoTutorials on May 28, 2010 14:15

actually I tried this, but it didn't work out for me this time... usually I prefer video tutorials, it's easier to implement anything when you are shown exactly what to do. but I'll for sure give my project another shot.

#18 - wrongful death case on June 05, 2010 11:53

Another great post admin. This is such good info for my research. I will bookmark your post here on Digg.

#19 - Student Debt Consolidation on July 01st, 2010 16:24

Great site you got here and all the posts are really worth the read. I was wondering if I could use some write-ups on my website, I will link back to your website or page where I took the article to properly cite the source. If this is a problem please let me know and I will take it down right away. Best regards - Karen

#20 - coach handbags on July 03rd, 2010 05:23


Cool post very informative I just found your site and read through a few posts although this is my first comment, i'll be including it in my favorites and visit again for sure .

#21 - mbt shoes on July 06, 2010 09:24

This kind shoes are very comfortable wearing. What's more, it have the function to protect knee. At the same time, it is also good for our body shape correction.

#22 - vegas casino online guide on July 13rd, 2010 20:26

Suppose it'll help me!
Thanks for the information provided!

#23 - cheap prom dresses on July 14, 2010 11:02

Thanks for the in-depth article. I can tell you put a lot of work into this one. Thumbs way up.

#24 - canadian pharmacy online on July 14, 2010 19:13

Maybe you should consider adding additional videos or charts to your weblog posts to make the visitors more entertained? I mean I just read through the entire post and it has been really great but since I'm more of a visual learner, some more vids and charts would help a lot. Nevertheless, the topic here is really worth pondering about. Thanks again.

#25 - Terry Winkle on July 16, 2010 06:57

Hello! nice article, thanks for sharing. <a href="http://www.savelovetoday.com/get-ex-back/relationship-can-be-saved-in-7-easy-steps/">how to save a relationship</a> | <a href="http://www.savelovetoday.com">saving a relationship</a> | <a href="http://www.savelovetoday.com/marriage/how-can-i-stop-my-divorce/">save the marriage</a> | <a href="http://www.savelovetoday.com/get-ex-back/you-can-win-back-lost-love-heres-how/">win back ex</a> | <a href="http://www.savelovetoday.com/get-ex-back/how-do-i-get-him-back/">get him back</a> | <a href="http://www.savelovetoday.com">getting ex back</a> | <a href="http://www.savelovetoday.com">want ex back</a> | <a href="http://www.savelovetoday.com">get her back</a> | <a href="http://www.savelovetoday.com">to get him back</a>

#26 - logo designs on July 19, 2010 13:49

this is what i needed man

#27 - Technology News on July 19, 2010 16:38

This tool or method whatever it is, it also has bug, but on the other hand some part of it did really well.

#28 - Ferrari replica watches on July 20, 2010 10:28

nice article. keep post like this...

#29 - Online Casino Promotions on July 20, 2010 14:07

I managed to install MultipleMediaPickerViaSource and it really makes multiple file selection more easy. Great job.

#30 - ipad converter on July 24, 2010 07:50

keep em coming the good content :)

#31 - domain name suggestions on July 24, 2010 08:31

Great site you got here and all the posts are really worth the read. I was wondering if I could use some write-ups on my website, I will link back to your website or page where I took the article to properly cite the source. If this is a problem please let me know and I will take it down right away. Thanks

#32 - cheapest home insurance on July 24, 2010 08:41

I will link back to your website or page where I took the article to properly cite the source. If this is a problem please let me know and I will take it down right away. Thanks

#33 - free online dating on July 24, 2010 17:37

Hi I've used this on a client's site and for the most part it's great. Unfortunately when media that is selected is deleted it leaves blank list items on the selected side that can't be removed. I've hacked the front end of the site to ignore the blank entries for now but is there a more elegant way to handle this?

#34 - chanel handbags on July 25, 2010 11:28

I thought to myself "it should take longer than 3 minutes

#35 - cheap chanel handbags on July 25, 2010 11:28

actually didn't took longer than 3 minutes of coding

#36 - coach outlet on July 25, 2010 11:29

kindly asked me how to extend/change

#37 - coach handbags on July 25, 2010 11:30

are succeeded with installing the MultipleMediaPickerViaSource

#38 - cheap coach handbags on July 25, 2010 11:30

MultipleMediaPickerViaSource to extend/change

#39 - shox shoes on July 25, 2010 11:31

MultipleMediaPickerViaSource is a Data Type where you

#40 - Wyler replica watches on July 26, 2010 11:22

nice article. keep post like this...

#41 - loan software on July 26, 2010 23:18

I've installed the MultiplePagePickerViaSource successfully - it works great as my 'download file' selector. Slight problem with the case when there is nothing selected though - I get this XSLT error:

#42 - stressballs on July 29, 2010 16:27

Thank you for providing such a valuable information on how to download and use this software.

 

Create a new comment

Recent Post

Tags