UPDATE after trying the OOTB list app:
I have a strange issue with placing a custom XSLT List View Webpartlist view web part on a publishing page layout.
My code:Note that this it true both for custom XSLT webpart and for the "App" for the list.
protected override void CreateChildControls()
{
using (var site = new SPSite(SPContext.Current.Site.ID))
{
using (var projectWeb = site.OpenWeb(Constants.Paths.ProjectWeb))
{
var publishingWeb = PublishingWeb.GetPublishingWeb(projectWeb);
var pagesLibrary = publishingWeb.PagesList;
var pagesListGuid = pagesLibrary.ID.ToString("B").ToUpper();
SPView view;
try
{
view = pagesLibrary.Views["Projekt"];
}catch
{
view = pagesLibrary.DefaultView;
}
listViewWebPart = new XsltListViewWebPart();
listViewWebPart.ListName = pagesListGuid;
listViewWebPart.ViewGuid = view.ID.ToString();
listViewWebPart.ViewId = int.Parse(view.BaseViewID);
listViewWebPart.XmlDefinition = view.GetViewXml();
listViewWebPart.JSLink = "/_layouts/15/myfolder/js/projectListTemplates.js";
listViewWebPart.Title = "Projekt";
listViewWebPart.DisableViewSelectorMenu = true;
listViewWebPart.InplaceSearchEnabled = true;
listViewWebPart.AsyncRefresh = true; // Have tried without this one
listViewWebPart.InitialAsyncDataFetch = true; // Have tried without this one
listViewWebPart.ClientRender = true;
listViewWebPart.ChromeType = PartChromeType.None;
Controls.Add(listViewWebPart);
}
}
}