Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Search for users based on custom feild in CMS Desk View modes: 
User avatar
Member
Member
matt.morgan-basecreativeagency - 5/21/2012 8:42:08 AM
   
Search for users based on custom feild in CMS Desk
Hi,

I created a new custom field for a user called UserNotes. I have made sure to tick as searchable under Development > System Tables > User > Search Fields and then rebuilt my search indexes. I can tested a search for the word 'lego' using the search preview tool and see the expected results, however when searching from within CMS Desk the expected results never display, is there a way I can customise the search fields this module uses to search, or have I done something wrong?

Thanks!
- Matt

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 5/21/2012 9:53:13 AM
   
RE:Search for users based on custom feild in CMS Desk
Hi,

first of all please take a look at properties of smart search web part and make sure that correct index is selected in the Indexes property.

Then try to use this transformation and search for username administrator. This user should be found if he exists.


<table style="margin-bottom:5px">
<tr>
<td>
<div style="border: solid 1px #eeeeee; width: 90px; height: 90px;">
<img src="<%# GetSearchImageUrl("~/App_Themes/Default/Images/CMSModules/CMS_SmartSearch/no_image.gif",90) %>"
alt="" />
</div>
</td>
<td>
<div style="margin-right: 5px; margin-left: 5px;">
<%-- Search result title --%>
<div>
<a style="font-weight: bold" target="_blank" href='<%# SearchResultUrl(true) %>'>
<%# SearchHighlight(HTMLHelper.HTMLEncode(DataHelper.GetNotEmpty(Eval("Title"), "/")),"<span style=\"font-weight:bold;\">","</span>") %>
</a>
</div>
<%-- Search result content --%>
<div style="margin-top: 5px; width: 590px;">
<%# SearchHighlight(HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(HTMLHelper.StripTags(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"), "")), false, " ")), 280, "...")),"<span style=\"background-color: #FEFF8F\">","</span>") %><br />
</div>
<%-- Relevance, URL, Creattion --%>
<div style="margin-top: 5px;">
<%-- Relevance --%>
<div title="<%# "Relevance: " + Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"),0.0)*100) + "%" %>"
style="width: 50px; border: solid 1px #aaaaaa; margin-top: 7px; margin-right: 6px;
float: left; color: #0000ff; font-size: 2pt; line-height: 4px; height: 4px;">
<div style='<%# "background-color:#a7d3a7;width:"+ Convert.ToString(Convert.ToInt32((ValidationHelper.GetDouble(Eval("Score"),0.0)/2)*100)) + "px;height:4px;line-height: 4px;"%>'>
</div>
</div>
<%-- URL --%>
<span style="color: #008000">
<%# SearchHighlight(SearchResultUrl(true),"<strong>","</strong>")%>
</span>
<%-- Creation --%>
<span style="color: #888888; font-size: 9pt">
<%# GetDateTimeString(ValidationHelper.GetDateTime(Eval("Created"), DateTimeHelper.ZERO_TIME), true) %>
</span>
</div>
</div>
</td>
</tr>
</table>


Now in case your custom field should not be used in the filter, i.e. for example using syntax:

+mycolumn:somevalue

change the field from Searchable to Content + Tokenized. The same setting as were used for UserName field.

Now you should see the result.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
matt.morgan-basecreativeagency - 5/21/2012 10:34:59 AM
   
RE:Search for users based on custom feild in CMS Desk
Hi Ivana,

Thanks for the timely response.

I would like the results to be returned when searching from the 'User' Module within CMS Desk, so that global admins can search for users that fit a specific criteria other than the default, name, email etc. Not a front end user search.

Is this easily achievable?

- Matt

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 5/22/2012 2:55:00 AM
   
RE:Search for users based on custom feild in CMS Desk
Hi Matt,

thank you for clarification.

Thu UI does not use smart search functionality. It is a simple SQL search which is implemented in the control UserFilter (file:///C:\<project>\CMSModules\Membership\Controls\Users\UserFilter.ascx). To the markup of this control you can add an own text box and label and then you will add a where part of condition to the AdvanceSearch() method.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
matt.morgan-basecreativeagency - 5/22/2012 3:14:27 AM
   
RE:Search for users based on custom feild in CMS Desk
Hi Ivana,

Thanks for coming back to me. I'm distressed I have to make changes to core functionality manually in order to achieve what should be a simple task. This will obviously have implication when we come to preform any updates in the future as I may need to fix any customisation I make now.

If that's the only way to achieve my goal then I have no choice, I am just a little disappointed that this system cant handle even the simplest customisation.

Thanks Ivana,
- Matt

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 5/22/2012 6:04:52 AM
   
RE:Search for users based on custom feild in CMS Desk
Hi,

the filter used in Users section is special and general unigrid functionality is not applied here (automatic filter).

This unigrid consists of multiple tables (and filter contains uniselectors).

In case we would use unigrid with a default filter (in this case adding a custom field would not be a problem, the current search functionality would not be supported.

There is an option - i.e. you can customize UI hotfix friendly way. It is described in the Customize Kentico CMS UI article (section Replacing the page with your customized page).

The code from above article (or similar to it) can be used in a custom class which will not be rewritten by hotfix:

Customization model

Best regards,
Ivana Tomanickova