Forum Discussion
Displaytemplate Urls in PnP templates
I took a quick look and I'm pretty sure the issue is caused by one of the following lines from ObjectPageContents.cs in OfficeDevPnP.Core
//some webparts already contains the site URL using ~sitecollection token (i.e: CQWP)
xml = Regex.Replace(xml, "\"~sitecollection/(.)*\"", "\"{site}\"", RegexOptions.IgnoreCase);
xml = Regex.Replace(xml, "'~sitecollection/(.)*'", "'{site}'", RegexOptions.IgnoreCase);
xml = Regex.Replace(xml, ">~sitecollection/(.)*<", ">{site}<", RegexOptions.IgnoreCase);
I also commented this in your submitted issue...
Interestingly enough these lines were added in an attempt to fix another issue you've submitted earlier :-)
- Feb 21, 2017
I guess we should use named groups in the regEx replace as described here:
http://stackoverflow.com/questions/12962114/how-to-use-named-groups-when-performing-a-regex-replace
- paulpaschaFeb 21, 2017Bronze Contributor
I don't understand issue #754 enough in order to be able to think of a good fix.
If I understand correctly CQWP uses the ~sitecollection token internally and it's exported together with your template. The current PnP code is trying to replace it with {site}. Honestly this doesn't make sense to me. The ~sitecollection token is recognized by CQWP (and other WebParts using it) so when importing (applying your template) the ~sitecollection token should still be included. Can you elaborate on this?
I've just submitted a pull request which undoes the changes made for issue #754. That should fix #1066 but #754 probably needs to be reopened now...
- Feb 21, 2017
Hi paulpascha,
The orignal issue had something to do with the location of the links wihtin the CQWP.
So imagine that you take a tempalate from
~sitecollection/subsite
and apply this to
~sitecollection/subsite/subsubsite
then the url is not correct.
There should be a token that holds the url of the web so that both ~sitecollection/subsite/subsubsite and ~sitecollection/subsite are referred to as {web}