1

I have been tasked with finding a way to display the site owner in the footer of all the web pages. I would assume that would be done via the Master Page but cannot find any information on I would accomplish this.

I have no code to show since I am just getting started and am doing the research. I am not the SharePoint Administrator, just a developer who has been given this task. We are using SharePoint 2013

2

check out the below code snippet, using JavaScript

var clientContext = new SP.ClientContext.get_current();
var site = clientContext.get_site();
clientContext.load(site, "Owner");
clientContext.executeQueryAsync(onSuccess, onFailure)
function onSuccess() {
   // get the owner name
   var owner = site.get_owner().get_title();

}
function onFailure(sender, args) {
   // handle error

} 
1

the ode provided by A.Saéed will extract the data you want to display, but it won't just display it,

you have several approaches from here

1.- place that code on each page and add some jquery or javascript to populate a control with the information you have 2.- Modify the masterPage

the safest approach to modify the master page is to use SP designer

Also you need to have the publishing feature enabled in both site and site collection.

i would recommend you to research on SharePoint Branding to find all the locations you have to look to safely customize the master page

  • Thanks for the help I am trying to come up with a plan to test the code and am having a problem. I created a site page and using embedded code I was able to populate the control with a string I created within the javascript. I would like to test the code provided above. But when I run the code I get an error which states "Unable to get property 'get_current' of undefined or null reference. Am I missing a reference or library on my staging server? – Perry Mar 6 '18 at 14:15
0

Thanks for your help I was able to use the code below to accomplish my goal

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js "></script>
    <script type="text/javascript" src="http://test.com/Style%20Library/JAVASCRIPT/jquery.SPServices-2014.02.min.js"></script>
    <div id='tblMain' style="float:left">
    <table id="myUsersTable"  border="1" cellpadding="2" width="400px">
        <tr>
        <th>Contact Names</th>
        </tr>
    </table>

    </div>
        <div style="float:left;">
            <asp:Label runat="server" ID="lblContacts" Text="Contact info"></asp:Label>
        </div>

    <script type="text/javascript">

    //wait until client object model dependencies are loaded before executing our code
    ExecuteOrDelayUntilScriptLoaded(getWebProperties, "sp.js");

    var webProperties;

    function getWebProperties() {
        var clientContext = new SP.ClientContext.get_current();
        webProperties = clientContext.get_web();
        this.groupOwnerUsers = webProperties.get_associatedOwnerGroup().get_users();
        clientContext.load(groupOwnerUsers);
        clientContext.executeQueryAsync(Function.createDelegate(this, this.getWebPropertiesSucceeded), Function.createDelegate(this, this.onQueryFailed));
    }

        function getWebPropertiesSucceeded() {

              var user = groupOwnerUsers.getEnumerator();

              while (user.moveNext()) {
                  if (user.get_current().get_title() != 'OCSO\\ims sharepoint site collectors')
                  {
                      //document.getElementById("lblContacts").innerHTML = 'contact';
                      document.getElementById("lblContacts").innerHTML = document.getElementById("lblContacts").innerHTML +', '+(user.get_current().get_title());
                      //document.getElementById("lblContacts").innerHTML = 'contact , ' + (user.get_current().get_title());
                      //document.getElementById("lblContacts").innerHTML =  document.getElementById("lblContacts").innerText + (user.get_current().get_title());
                      AddRowToTable(user.get_current().get_title());
                  }

                  }

               }


    function onQueryFailed(args, sender)
    {
        alert('Error: ' + args.get_message());
    }

    function AddRowToTable(OwnerName)
    {   
    $("#myUsersTable").append( 
       "<tr>"+
       "<td >" + OwnerName + "</td>" +
       "</tr>"); 
    }

    </script>

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.