0

We have a publishing site in SharePoint Online which has News Page layout (Custom page layout) associated with default publishing page library.

when we are searching any pages, we are able to get preview of pages having default SharePoint page layout. but we are not able to get preview of pages having custom page layout.

E.g.

default SharePoint page layout:

enter image description here

custom page layout:

enter image description here

Any help will be appreciated... :-)

0

Finally I solved it.

Cause:

When I checked inspect element for custom page layout, i found that it was referring Item_default.js and callback was set for Item_default_hoverpanel.js.

i.e.

onfocus="EnsureScriptParams('SearchUI.js', 'HP.Show', 'ctl00_PlaceHolderMain_ctl01_csr4_item', 'ctl00_PlaceHolderMain_ctl01_csr4_hover', '~sitecollection\u002f_catalogs\u002fmasterpage\u002fDisplay Templates\u002fSearch\u002fItem_Default_HoverPanel.js', false);"

And for default webpage it was referring Item_Webpage.js and callback was set for Item_Webpage_hoverpanel.js

i.e.

onfocus="EnsureScriptParams('SearchUI.js', 'HP.Show', 'ctl00_PlaceHolderMain_ctl01_csr2_item', 'ctl00_PlaceHolderMain_ctl01_csr2_hover', '~sitecollection\u002f_catalogs\u002fmasterpage\u002fDisplay Templates\u002fSearch\u002fItem_WebPage_HoverPanel.js', false);

Solution:

I edited Item_default.html (bcz we cannot edit js file directly) and changed callback to Item_WebPage_HoverPanel.js

i.e. Changed below line of code from Item_default.html

<!--#_ 
    if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){
        var id = ctx.ClientControl.get_nextUniqueId();
        var itemId = id + Srch.U.Ids.item;
        var hoverId = id + Srch.U.Ids.hover;
        var hoverUrl = "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default_HoverPanel.js";
        $setResultItem(itemId, ctx.CurrentItem);
        if(ctx.CurrentItem.IsContainer){
            ctx.CurrentItem.csr_Icon = Srch.U.getFolderIconUrl();
        }
        ctx.currentItem_ShowHoverPanelCallback = Srch.U.getShowHoverPanelCallback(itemId, hoverId, hoverUrl);
        ctx.currentItem_HideHoverPanelCallback = Srch.U.getHideHoverPanelCallback();
_#-->

to

<!--#_ 
    if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){
        var id = ctx.ClientControl.get_nextUniqueId();
        var itemId = id + Srch.U.Ids.item;
        var hoverId = id + Srch.U.Ids.hover;
         var hoverUrl = "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_WebPage_HoverPanel.js";
        $setResultItem(itemId, ctx.CurrentItem);
        ctx.currentItem_ShowHoverPanelCallback = Srch.U.getShowHoverPanelCallback(itemId, hoverId, hoverUrl);
        ctx.currentItem_HideHoverPanelCallback = Srch.U.getHideHoverPanelCallback();
_#-->

And it started working and preview is showing for custom pages. :-)

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.