0

I am building a display template. There is a control template and a item template. In the item template I have some a href tag. In this a href tag I would like to link to some page inside the current site collection. How can I implement this?

This is not working:

var Body = '<table id="StandPuntTable">' +
            '<tr><td>' + Bestuurder + '</td></tr>' +
            '<tr><td><H1>' + Title + '</H1></td></tr>' +
            '<tr><td><img src="/sites/khha/_catalogs/masterpage/test/images/tag-underline.png" /></div></td></tr>' +
            '<tr><td>' + IntroText + '<br></br></td></tr>' +
            '<tr><td><a href="/Pages/Standpunt-detail-lijst.aspx?standpuntID=' + ListItemID + '" class="leesMeer"><img src="/sites/khha/_catalogs/masterpage/test/images/lees-meer.png" />Lees de volledige toelichting</a></td></tr>' +
            '<tr><td><a href="/Pages/Standpunt-detail-lijst.aspx" class="button-right">Alle onze standpunten op een rij</a></td></tr>' +
            '</table>';

The link is going to the root site collection, but I have also sub site collections. So I would like to refer to this page in the current site collection.

1

How about the classic double dot?

../Pages/Standpunt-detail-lijst.aspx

Taking away the Pages part of the current page and then appends your string.

0

I have found this solution: var currentSiteCollectionFullUrl = window.location.protocol + '//' + window.location.host + _spPageContextInfo.siteServerRelativeUrl;

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.