Hello all,
Is there a way to change the No results message in the search core results webpart with xslt.
Thanks for the help.
Best Regards,
André
Technology Tips and News
Hello all,
Is there a way to change the No results message in the search core results webpart with xslt.
Thanks for the help.
Best Regards,
André
Mike, have you tried to modify exqctly this part of the xsl yourself? Because, when I tried I had no success with modifying the dvt_1.noKeyword template, while for instance modifying the dvt_1.empty template is not a problem. You can even remove the call for the template from the main template (match="/"), and it has no effect. I am wondering if this is a message that is output from somewhere else than the XSL, and it would be great if someone confirmed whether this is the case or not. There's another post in a Sharepoint 2010 forum that explains how you can remove this message by using jquery to remove the node that is output, and apparently that was a successful hack. However, it _should_ be possible to do it in the xsl. I haven't been able to make it work, though.
edit: link to the post I mentioned above: http://social.technet.microsoft.com/Forums/en-US/sharepoint2010general/thread/08bec7c2-c7da-41cd-a718-3fd754ceeb4a
I don't think that this is the correct answer, in fact I think this is the intended functionality but I'm quite sure that if you try this you'll see that it doesn't work.
Mike, did you propose this answer yourself? I feel that if something is going to be marked as an answer it should at least be accurate. Better still, it should contain some useful instruction on how to resolve the problem.
I wasted hours of life on this problem, expecting that I was clearly doing something stupid. Because surely there's NO WAY this message is acceptable for public-facing web sites.
My final solution - and by far the simplest - was to simply override the srch-wperror CSS class.
.srch-wperror {display:none !important}
Mike,
This message shows up on the screen even when you remove ALL xsl transformation and simply echo the XML back as below.
<?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /> <xsl:template match="/"> <xmp> <xsl:copy-of select="*" /> </xmp> </xsl:template> </xsl:stylesheet>
Hi,
this message comes from resource file embedded into assembly
microsoft.office.server.search.intl.dll
and for
Core Results web part this message renders when Query Error occurs instead of displaying actual search result, this is why for this message XSLT customization could not be applied as for regular search results.
But it could be customized on the client side, for example the script below (jQuery is used here) changes this message:
$(function()
{
var srchErrorLabel = $('.srch-wperror').find('span');
srchErrorLabel.text('Place user friendly message here');})
So, if you add on page where
Core Results web part is located this script, the message
Place user friendly message here
will be displayed.
Hope this helps,
Vadim
Hi ,
You can do it using javascript function.
$(function()
{
var srchErrorLabel = $('.srch-wperror').find('span');
srchErrorLabel.text('Place user friendly message here');
})