1

Still pretty new to share point. I'm trying to get the data of a web part to display on every page but don't know how. Any ideas on how I can do this. Thanks in advance.

  • Hi. Wich kind of Data? Wich kind of webpart? – Juan Pablo Pussacq Laborde Mar 19 '15 at 18:00
  • some text entered into a list form. – Dz1 Mar 19 '15 at 18:01
  • If you need the text in all pages, like a header or footer, you need to alter the master page. Are you talking about something like header and footer? – Juan Pablo Pussacq Laborde Mar 19 '15 at 18:22
  • A rotating alert of three. I know it should reside on the master page but I can't figure out how to get it to display. – Dz1 Mar 19 '15 at 18:24
3

From MSDN for SharePoint 2013.

If you want complete control over how a Web Part appears on your site, and if you want that Web Part to appear on all pages of a certain type, add the Web Part directly to a page layout. If you want a Web Part to appear on all pages in a site, you can also add a Web Part directly to a master page.

Try with this article: How to: Add a Web Part zone snippet in SharePoint 2013

1

There are several way to achieve this goal. The easiest and straight forward way is

  1. Edit the master page and add a div tag - This is the place where the dynamic text will get populated

    <div id="rotatingNews" />
    
  2. Now using Client Object Model OR SPServices OR REST you read the information from the List and Populate the div. You can use jQuery plugins to rotate the news or you can write simple JavaScript to switch the data

    _spBodyOnLoadFunctionNames.push("PopulateRotatingNews");  
    
    var news;
    function PopulateRotatingNews() {
        var context = new SP.ClientContext.get_current();
        var web = context.get_web();
        var list = web.get_lists().getByTitle('NewList');
        news = list.getItems(''); //Get all items
        context.load(news, 'Include(Text)'); //Text is the field internal name we are trying to pull data from
        context.executeQueryAsync(Function.createDelegate(this, onSuccess), Function.createDelegate(this, onFailure));
    }
    
    onSuccess() {               
        var newsCollection = news.getEnumerator();
        var html = ''
        while (newsCollection.moveNext()) {
            var n = newsCollection.get_current();
            html += "<p>" + n.get_item('Text') + "</p>";
        }
    
        $('#rotatingNews').html(html);
    }
    
    function get_Employees_onFailure() {
        alert("Failed");
    }
    

You can choose among JSOM/REST and choose a compatible Plugin for rotating the items.

  • Which is your sharepoint version. – Amal Hashim Mar 26 '15 at 12:52
  • The version is 2013 – Dz1 Mar 26 '15 at 12:53
  • Try this - enjoysharepoint.com/Forum/Details/…. I would still suggest you follow the approach I explained in the answer, that is how we should do in 2013. – Amal Hashim Mar 26 '15 at 12:58
  • I'll let t you know how it goes in a bit. – Dz1 Mar 26 '15 at 13:07
  • +1 I'm not sure why this answer has been downvoted – Vadim Gremyachev Mar 30 '15 at 12:12
0

Web parts are designed be placed into individual pages via web part zones. But if you need something more common to "all pages" then you are going to need to look at working with the master page or layout pages depending on your situation. If the content you want to display is dynamic (in part because it is looking at a list item) then you'll need some form of control or perhaps javascript that grabs the data and shows it to users. In short, you can't place list web parts in a master page.

  • It is dynamic and one can't be adding it one by to every page so i'm looking for a way to output it to every page from one point. – Dz1 Mar 19 '15 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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