0

I have a JSLink function overriding the default footer of a list view webpart. How can I retrieve this list's title (or URL) so that it can be added to the footer?

(function () {

var overrideContext = {};
overrideContext.Templates = {};
overrideContext.Templates.Footer = overrideCustomFooter;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext); })();

function overrideCustomFooter() {
return "<div><a href='https://somesite/Lists/[LIST TITLE]'>See more</a></div>"; }

Thank you very much in advance!

clnns45
  • 39
  • 7

1 Answers1

1

There are several options available:

  1. Via SP.PageContextInfo object:

The following example absolute url of list:

const  listBasUrl = _spPageContextInfo.webAbsoluteUrl + _spPageContextInfo.listUrl
  1. Via context passed into Templates.Footer function:

ctx.listUrlDir -server relative url to List

Example

function renderFooter(ctx){
    console.log(ctx.listUrlDir);
    return "";
} 

where

SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
  Templates: {
       Footer: renderFooter
  },
});
Vadim Gremyachev
  • 57,952
  • 20
  • 129
  • 193
  • 1
    Yes. approach #2 seems to work. Thank you very much! However, for some reason the footer is now added on all webparts on that page and it disappear after navigating forward and back to that page. Do you have any idea why? – clnns45 Oct 29 '18 at 11:10