I'm in a situation where I'm using the Multi-Node Tree Picker datatype to let the administrator choose several media items for his news. At the moment I'm developing a "mirror-site" for his mobilephone so he's able to write news on-the-road. The only thing left on this site is to let him upload a picture (just a single picture) by using the asp FileUpload control. When the upload is done and the media item is being returned, I would like to add the media item to the Multi-Node Tree Picker datatype on the News document type. This should be done from C# aswell.
Is this possible at all? Any help/hint on this will be greatly appreciated! :)
If you want to store several media items in 1 picker I currently have a media picker which can do this. If you're interessted I can send the Release Candidate. Besides selecting multiple media item it also has an upload option which isn't in MNTP.
As Jeroen says, you can easily set the value for MNTP programmatically. I'd advise using CSV-based values, as it would be much easier to do - literally just assign it the media Id.
Media m = new Media(1146);
doc.getProperty("billeder").Value = m;
doc.Save();
doc.Publish(new User(0));
umbraco.library.RefreshContent();
Where "billeder" is the Multi-Node Tree Picker datatype. It doesn't give me any errors at all, but the media is not added to the Selected Items in the Multi-Node Tree Picker.
Also, I've tried to set the "billeder" property to m.Id, but that doesn't work either..
O.k so I just had a peek into the database to see what data is stored when you add images/documents to the MNTP datatype. It seems it's stored as XML like:
Multi-Node Tree Picker: set nodes programatically
Hi all,
Thanks for a great module for Umbraco! :)
I'm in a situation where I'm using the Multi-Node Tree Picker datatype to let the administrator choose several media items for his news. At the moment I'm developing a "mirror-site" for his mobilephone so he's able to write news on-the-road. The only thing left on this site is to let him upload a picture (just a single picture) by using the asp FileUpload control. When the upload is done and the media item is being returned, I would like to add the media item to the Multi-Node Tree Picker datatype on the News document type. This should be done from C# aswell.
Is this possible at all? Any help/hint on this will be greatly appreciated! :)
Thanks in advance,
Bo
Hello,
You can update the data in the property using the Document API. If you store your nodes as xml you just need to create the xml in the correct format and update the property. Read more about it here: http://our.umbraco.org/wiki/reference/api-cheatsheet/modifying-document-properties.
If you want to store several media items in 1 picker I currently have a media picker which can do this. If you're interessted I can send the Release Candidate. Besides selecting multiple media item it also has an upload option which isn't in MNTP.
Jeroen
Hi Bo,
As Jeroen says, you can easily set the value for MNTP programmatically. I'd advise using CSV-based values, as it would be much easier to do - literally just assign it the media Id.
Cheers, Lee.
Hi Jeroen,
Thanks for your quick response! :)
I have tried the following:
Where "billeder" is the Multi-Node Tree Picker datatype. It doesn't give me any errors at all, but the media is not added to the Selected Items in the Multi-Node Tree Picker.
Also, I've tried to set the "billeder" property to m.Id, but that doesn't work either..
O.k so I just had a peek into the database to see what data is stored when you add images/documents to the MNTP datatype. It seems it's stored as XML like:
.. as regular text.
I tried to do this in C#:
.. and it works like a charm! :)
is working on a reply...