0

I'm looking for ressources about how to add a webpart to display the content of list using custom xsl in the master page.

Say I got a list called "sponsors" with : name, url link, image link... I got no problem to add a webpart that displays the content of this list with a custom presentation (xsl). Now I just want to do it in the masterpage. I'd thought it would work in the design manager (_layouts/15/DesignMasterPages.aspx) like it works in a page, then I'd have copied/pasted pasted the escaped version into the master page and end of the story.

This was 4 hours ago.

In the designer ribbon there are a lot of "data sources" for dynamic content (blog, whole documents, forms, social collaboration, search driven content, search results,community) most of them seem of no (or little) use to me compared to listing the content of lists. It is such a basic need that I surely missed something but what ?

(It was easier to get a working javascript solution.)

Any pointers appreciated. Thank you.

3
  • Why you want list data on master page, master page serve the function of rendering common design element for the SP site. May be consider page layout with JSOM.
    – bkk
    Sep 5, 2016 at 17:24
  • I got a list of sponsor in the footer and I want power user to be able to add new entries in the list and not mess with the master. In the design manager/code snippets you can add menus/navigation/logo/connexionInfo [webpart]. You can even add webparts based on "dynamic content" [such as ToC]. If those things are eligible for master page then I think a customized list fits too. Maybe it will be better in page layout. dunno. Wherever I put this in, I don't want the users to be able/have to tweak it. They just feed it through the list and that's it. Any pointer if I choose page layout finally?
    – frenchone
    Sep 6, 2016 at 8:05
  • Have replied with my answer, let me know if it helps or if you need more input. Same approach will work in case you decide to use page layout.
    – bkk
    Sep 6, 2016 at 8:45

1 Answer 1

1

Place a div as placeholder in the master page.

Then include a JS file with JSOM code to fetch the custom list items and build your HTML before injecting it inside the div.

Note - There are umpteen samples on the net explaining how to write JSOM code to fetch list items.

3
  • This is what I've done. But it looks bizarre to me that using design manager you can add easily add a menu and lot of fancy but not that usefull things but you cannot bind on a view list. What if the javascript is disabled on browser ? Another sharepoint oddity I guess. I left bug opened in case someone gets with a better solution.
    – frenchone
    Sep 6, 2016 at 9:18
  • if you want to mitigate the risk of JavaScript being disabled then consider custom user control. ref. sharepoint.stackexchange.com/questions/58749/…
    – bkk
    Sep 6, 2016 at 10:44
  • What I really wanted was a no hassle solution. For me and for contributors. But it looks like this does not exist. I'll go with the pure JS solution. Deploying an user control would be just another occasion to break the whole thing
    – frenchone
    Sep 6, 2016 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.