Could have sworn i deleted this topic, as i came to the solution myself. Thanks for the help anyway Dennis. Not sure i understand fully what you mean however.
For anyone who comes into a similar problem, or if I'm doing it completely wrong, here's what i did;
Document Types Master -> Home -> Text Page -> Media Folder (this has a multiple media picker property called media)
Content Home (Home document type) -> About (Text page document type) -> Banners (Media folder document type)
and my partial view;
@inherits UmbracoTemplatePage
@{ var homePage = CurrentPage.AncestorsOrSelf(1).First(); var bannerPage = homePage.umbMediaFolder.Where("Name == @0", "Banners").First(); }
Access media globally
Hi,
I'm having trouble accessing the same media folder for every page.
Ihave a setup as follows:
Document types
Master
-> Home
-> About
-> etc
Templates
Layout
->Home Page
-> Text Page
-> etc
Under the media tab i have a folder called 'Banners' which has a number of images in it.
My Layout contains something along the lines of;
Essentially, i need the umbBanner partial view to access the same media items for every page.
Any help would be greatly appreciated. If you need any more info, please let me know.
Thanks,
Luke.
Hi Luke,
I assume that you are picking the folder with image on the front page documenttype and then want the same image on all other pages.
If so you need to call the partial view recursive, so it goes up in the content tree until it found the field where it´s not empty.
You can call a property rerecursive like this for strongly typed razor:
or if you are using dynamic razor
The documentation can be found here: http://our.umbraco.org/documentation/Reference/Querying/DynamicNode/Properties
If I remember correct you can also call the partial view recursive, by simply do this:
http://our.umbraco.org/documentation/Reference/Mvc/views#RenderingafieldwithUmbracoHelper
Hope this helps,
/Dennis
Could have sworn i deleted this topic, as i came to the solution myself.
Thanks for the help anyway Dennis. Not sure i understand fully what you mean however.
For anyone who comes into a similar problem, or if I'm doing it completely wrong, here's what i did;
Document Types
Master
-> Home
-> Text Page
-> Media Folder (this has a multiple media picker property called media)
Content
Home (Home document type)
-> About (Text page document type)
-> Banners (Media folder document type)
and my partial view;
is working on a reply...