Portal Tip - Modifying the Search Dropdown Menu
Just wanted to share with Portal users a way to modify, or even remove functions of the search drop-down menu that you see at the top of the page.
Say, you want to remove the dropdown altogether, and have users only be able to search for Work Items (the default search option), you can add this line of code within the custom.js file (for most users, it will be in C:\inetpub\CiresonPortal\CustomSpace. Otherwise, defer to your install path and locate the CustomSpace folder within):
/* Hide Search Options */If you are interested in removing a single option, say, Knowledge Base, you can put in the following code into the custom.css file. The same can be done with the Service Catalog.
.input-group-btn {
display: none;
}
$(document).ready(function () {However, if you only want to have a single searchable option. For example, if you want to have just the Knowledge Base to be searchable, you would put in the following code in the custom.js file in your CustomSpace folder.
$('.dropdown-menu [href="#KnowledgeBase"]').parent().remove();
});
$(document).ready(function () { $(".navbar__search--dropdown > ul").html('<li><a href="#KnowledgeBase">Knowledge Base</a></li>'); var searchParam = $("input[name=search_param]"); //the hidden field which holds the search type id var searchConcept = $("span[id=search_concept]"); //the span field which displays the search type value var searchInput = $("input[name=searchText]"); //the input field which takes the input from the user searchParam.val("KnowledgeBase"); searchConcept.html(localization.KnowledgeBase); searchInput.attr('placeholder', localization.SearchKnowledgeBase); });Please note that changes would affect all users that access the Portal.
Comments
Thanks for this helpful code snippets!
For the second one, there is a little fault in your text:
"If you are interested in removing a single option, say, Knowledge Base, you can put in the following code into the custom.css file. The same can be done with the Service Catalog."
--> this should be added in the custom.js file
Best wishes,
Adrian
I've been looking at defaulting our search dropdown to work items. I'm wondering why in your snippet you call out the 3 individual components of the dropdown instead of addressing it though the kendo object?
Thank you!
https://support.cireson.com/KnowledgeBase/View/43#/
As for hiding it just for end users, I haven't done any testing on this specifically and honestly, I am not sure if it can be done without some sort of modification of the internal code itself.
if (session.user.IsAdmin === false) {
$(".navbar__search").hide()
};
The above CSS from @Martin_Blomgren is way better though, and super awesome.
The only thing I have been able to use to hide the header nav search bar so far is the below but it of course hides from both analyst and end users:
A variation of that may work. You just need to figure out what your admins have in common vs your standard users.