0

We have several sites we build for different departments across our enterprise. All of our sites have a footer with links like About, Help, Contact. On each site those point to different urls and/or have slightly different text, for example one might say "About our program" and another might say "About us".

Up until now we have either had to create new page layouts for each site or put a webpart zone on each page. Both of those approaches get to be unmanageable as we get more sites and more content in them.

We would like to add the footer to the master page. And I've found many tutorials that show how to add a set footer like a copyright to the bottom of the master page. But we can't do that because each site has slightly different things it needs in the footer.

Is there some way I could add something to the masterpage like the following:

 include ~site/SiteAssets/my-local-footer.html

And then all the different site owners would need to do is put an html file in their site assets folder.

<li><a href="site/about">About our program</a></li>
<li><a href="site/faq">Help</a></li>
<li><a href="site/contact">Drop us a line</a></li>

We don't have access to central admin and can't deploy any custom webparts or apps.

I used the snippet editor to create a content editor webpart and put a absolute url to a file into the content link and that worked. But I can't figure out how to make the url relative to the current site.

I tried using the ~site token, but then the webpart gives me a "cannot retrieve the url" error. I also tried to take a page from the custom cssregistration links and tried to replace the content link with

<!--SPM:&#60;% $SPURL~site/SiteAssets/my-local-file.html  %&#62;-->

But that produce an error about using FORMS.

Master pages are a big mystery to me and I'm sure there is some simple concept I'm completely missing. Is there a way to have a different local file load onto the masterpage for each site?

4
  • did you just tried "/site/faq" it should make it relative to site collection.... ? Commented Sep 28, 2016 at 16:54
  • It sounds like you want to use Reusable Content, where each site collection can specify their own footer and it is utilized in the footer of your page layout/master page. Commented Sep 28, 2016 at 17:03
  • Siddharth Vaghasia - It won't work because we have all of our sites have different names. We want a masterpage we can use across multiple sites and subsites.
    – Rothrock
    Commented Sep 28, 2016 at 17:12
  • Eric Alexander - Reusable Content seems interesting. I created a new reusable html item in the Reuse Content list. But how do I get that item on each page in the site?
    – Rothrock
    Commented Sep 28, 2016 at 17:25

2 Answers 2

1

I would suggest a different approach to getting a custom footer on the master. It would involve doing one Rest call on the Reusable Content list and fetching the data from the list and binding it to the html.

Create a <footer> tag in the masterpage like <footer id="siteFooter">. Now at the bottom of the masterpage just above </body> tag, create a custom js file and make a rest call to get data from list and bind it. The code in the js should be something as mentioned below. I am assuming that you are using a javascript framework like jQuery or angular or knockout and referencing them in masterpage . By using this approach , the user can directly edit items in the list and it will get reflected directly without the headache of uploading the html every time you want to change footer.

 $(document).ready(function() {

    createFooter();

});

    function createFooter(){
    $.ajax({
                url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Reusable Content')/items?$select=ReusableHtml",
                method: "GET",
                headers: { "Accept": "application/json; odata=verbose" },
                success: function (data) {
                    if(data.d.results.length>0){
                        $('#siteFooter').append(data.d.results[0].ReusableHtml);
                    }
                    else
                    {
                        console.log("no footer data");
                    }

                },
                error: function (data) {
                    console.log(data);
                }
          });
    }
1
  • I had thought of maybe doing something like this. The main thing was I was hoping to avoid having to make network calls and deal with the delay -- especially on mobile.
    – Rothrock
    Commented Sep 30, 2016 at 16:39
0

We actually came up with a different approach. We weren't using the side/current navigation on our site. So we created a side nav snippet and put it in the footer on our masterpage.

That way we can use the same managed navigation termset for our top main navigation and the bottom navigation where we put the more "housekeeping" kind of links. And with a little styling it offers us great functionality and integrates directly with the rest of our navigation.

Of course if we were to need the side nav I'm not sure what we would do.

Your Answer

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

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