Hi I am fairly new to umbraco 7. I need to create a download links menu on a page which has links to PDF documents.
I have tried doing some searching and can see either to use media picker or file upload.
file upload is no good as I need to be able to select multiple documents and the media picker does not seem to work, as it gets the pdf document as an image picker.
any one have a link to any documentation on this, preferably to do it dynamically
Yes, a multiple media picker is the correct approach, and in the past this has allowed you to pick and upload multiple documents (not necessarily images) for sections such as you describe.
However a recent introduction to allow the media picker to be restricted to images only, configurable on the datatype, has caused a few issues:
@{
var relatedMediaList = CurrentPage.DownloadLinks;
var relatedMediaIds = relatedMediaList.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var relatedMedia = Umbraco.Media(relatedMediaIds);
}
@foreach (var file in relatedMedia)
(and remove your line: var file = CurrentPage.MediaById(d.InnerText);)
I've broken this down so you can see what is happening, the Media Picker, stores a comma delimited list of the ids of the picked media, and Umbraco.Media has an overload that excepts a string array of ids and then returns an enumerable of the media items. So you can just loop through those and the rest of your code should work...
Uploading PDF's
Hi I am fairly new to umbraco 7. I need to create a download links menu on a page which has links to PDF documents.
I have tried doing some searching and can see either to use media picker or file upload.
file upload is no good as I need to be able to select multiple documents and the media picker does not seem to work, as it gets the pdf document as an image picker.
any one have a link to any documentation on this, preferably to do it dynamically
Thanks
Nav
Hi Naveed
Yes, a multiple media picker is the correct approach, and in the past this has allowed you to pick and upload multiple documents (not necessarily images) for sections such as you describe.
However a recent introduction to allow the media picker to be restricted to images only, configurable on the datatype, has caused a few issues:
issues.umbraco.org/issue/U4-8016
but it seems in 7.4.3 you can pick PDFs again!
regards
Marc
hi thanks for the reply, I have just checked and I am using 7.4.3..
this is my razor code in the view:
} }
Hi Naveed
Try replacing your line
with
(and remove your line: var file = CurrentPage.MediaById(d.InnerText);)
I've broken this down so you can see what is happening, the Media Picker, stores a comma delimited list of the ids of the picked media, and Umbraco.Media has an overload that excepts a string array of ids and then returns an enumerable of the media items. So you can just loop through those and the rest of your code should work...
regards
Marc
Thanks for the help.. I have replaced the code..but still cant get it to work.. What data type should I be using??
Hi Naveed
A Multiple Media Picker.
Here is the full code of the macro partial:
So if I pick some pdfs
this is the result of the macro:
Thank You so much that is working perfectly now :-)
I will mark the answer so other people can find the solution too
Again thank you a lot
Yes, go with macro is good solution
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.