如何根据列表名称更改搜索结果显示模板? [英] How to change the search result display template based on list name?

查看:81
本文介绍了如何根据列表名称更改搜索结果显示模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据列表名称设置搜索结果的格式.

I want to format the search result based on the list name.

例如:如果数据来自ListName1,那么我想更改搜索结果中的项目URL.对于其他所有结果,我什么也不想做.

For example: If data is coming from ListName1 then I want to change the item URL in the search result. For all other result, I don't want to do anything.

所以我想知道我该如何实现?我应该修改哪个文件以及如何检查列表名称?

So I want to know How can I achieve this? Which file I should modify and How I can check for the list name?

推荐答案

嗨TrimantraLLP,

Hi TrimantraLLP,

是的,您可以通过修改显示模板来实现.

Yes, you can achieve it via modifying the display template.

为您执行以下步骤:

1.使用SharePoint Designer 2013打开搜索中心网站.

1. Open your Search Center site using SharePoint Designer 2013.

2.转到所有文件"-> __ catalogs->母版页->显示模板->搜索,然后编辑文件"Item_CommonItem_Body.html".

2. Go to All Files->_catalogs->masterpage->Display Templates->Search, and edit the file Item_CommonItem_Body.html.

3.找到该行

var truncatedUrl = Srch.U.truncateHighlightedUrl(displayPath, pathLength);

4.在步骤3中的行下添加以下代码:

4. Add the following code under the line in step 3:

 if(truncatedUrl.indexOf("List1")>0){
            	truncatedUrl="Custom List";
            }

结果是:

在上面的代码中,您需要将"List1"更改为到您的列表并更改自定义列表"到您的文本.

In the above code, you need to change "List1" to your list and change "Custom List" to your text.

谢谢

温迪


这篇关于如何根据列表名称更改搜索结果显示模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆