How to redirect to a custom user profile page for people search in sharepoint2010?

Hi All,

In Sharepoint People search when we search for a person it redirects to the peopleresults.aspx with the required result and when we click on the person's name it redirects to the user profile page of the person's account.

Can it be possible to redirect the page to a custom user profile page on click of the person's name in the peopleresults.aspx.

What changes can be done and where it should be done to achive the desired output.

Please suggest....

Thanks

Suu30

November 22nd, 2012 1:31pm

Edit the webpart "People Search Core Results"

uncheck "Use location Visualization" then you can edit the XSL (XSL Editor)

In the XSL you can change the link.

Free Windows Admin Tool Kit Click here and download it now
November 22nd, 2012 2:34pm

The "userdisp.aspx" page contains a delegate control (see below) which is responsible for redirecting to the profile page for a given user.  It would be best if you create a custom delegate that contains your redirect logic as this would then apply everywhere within the site your feature is activated on.

<SharePoint:DelegateControl runat="server" id="DelctlProfileRedirection" ControlId="ProfileRedirection" Scope="Farm" />

If you are not familar with delegate controls please see the following which in the "Community Content" section contains an example of a custom profile redirection delegate: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.iformdelegatecontrolsource(v=office.12).aspx

November 22nd, 2012 4:57pm

Thanks for the reply....

I went through the given links, but i am not able to follow where exactly I need to do the changes to get the result.

Shall I create a new feature in visual studio and add the code for changing the redirection path using the delegate control?or anything other than this?

Can you please explain me the steps to do this successfully?

Please help.... 

Regards

Suu30

Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2012 10:16am

If i'm right you want that when you click on one of the results (name or picture) you want to link to another page than the default one?

If yes, as I said, change the XSL

You need to change this for the picture:

  <div id="UserPhoto">
    <a href="http://www.google.com" id="{concat($currentId, '_CSR_IMGL')}" title="{preferredname}">
      <xsl:variable name="imgid" select="concat('CSR_IMG_',$id)"/>
      <xsl:variable name="purl">
        <xsl:call-template name="GetPicUrl">
          <xsl:with-param name="PicUrl" select="pictureurl"/>
          <xsl:with-param name="PlaceHolderUrl" select="'/_layouts/images/o14_person_placeholder_96.png'"/>
        </xsl:call-template>
      </xsl:variable>
      <img id="{$imgid}" src="{ddwrt:EnsureAllowedProtocol(string($purl))}" alt="{preferredname}" border="0"></img>
    </a>
    <xsl:if test="$hascol">
      <div id="ColleagueField">
        <xsl:value-of select="colleaguecategory"/>
      </div>
    </xsl:if>
  </div>

And for the name:

<div id="ContactInfo">
    <ul id="MiniContactCard">
      <li id="NameField">
        <xsl:if test="$haspn">
          <a href="http://www.google.com" id="{concat($currentId, '_CSR')}">
            <xsl:apply-templates select="hithighlightedproperties/preferredname" />
          </a>
        </xsl:if>
      </li>
...

I changed it, and now I'm going to google if I click on picture or name
November 23rd, 2012 11:23am

Hi,

Thanks for the suggestion,but will it redirect to a custom user profile page of the same person...because the query string value is different for different person.for e.g the link is

http://servername:portnumber/Person.aspx?accountname=Domain%5CSucharita%5FDansana

here the account name will be different for every user...How to achive this with the above suggested code?

Please suggest...

Thanks

Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2012 1:30pm

We've done a similar thing.

In your xslt used in the core-results webpart, change the URL used when clicking on the users name/photo, so that it opens an application page in a modal dialog (you'll need to attach a javascript file containing the OpenDialogNoRefresh method - which is just using SharePoint modal dialog framework). E.g.

<div class="inceSearchUserPhoto">
  <div id="mouseover" onclick="javascript:OpenDialogNoRefresh('http://inceweb/_layouts/ince.searchparts/peopledetails.aspx?person={$username}','{preferredname} - {$username}')">
	<xsl:variable name="imgid" select="concat('CSR_IMG_',$id)"/>
	<xsl:variable name="purl">
	  <xsl:call-template name="GetPicUrl">
		<xsl:with-param name="PicUrl" select="pictureurl"/>
		<xsl:with-param name="PlaceHolderUrl" select="'/_layouts/images/ince/anon.jpg'"/>
	  </xsl:call-template>
	</xsl:variable>
	<img id="{$imgid}" src="{ddwrt:EnsureAllowedProtocol(string($purl))}" alt="{preferredname}" border="0"></img>
  </div>
<xsl:if test="$hascol">
  <div id="ColleagueField">
	<xsl:value-of select="colleaguecategory"/>
  </div>
</xsl:if>
</div> 

Your application page should read the query string parameter person, and use that to display the persons details from the User Profile Application. E.g.

SPServiceContext serviceContext = SPServiceContext.GetContext(mysite);
UserProfileManager upm = new UserProfileManager(serviceContext);
String samAccount = String.Format("domain\\{0}", person);
if(!upm.UserExists(samAccount))
{
RenderError(String.Format("{0} does not exist in the SharePoint User Profile Store.", person));
return;
}
UserProfile up = upm.GetUserProfile(samAccount);
//Output the required user properties

Ours looks like this:

November 23rd, 2012 1:45pm

thank u for the suggestion

I have already gor a custom user profile page...

I just want to redirect to the custom profile page on click of the username or photo in the peopleresults.aspx an my doubt is the username is dynamic....so How to resolve the issue?

Any suggestion please....

Regards

Suu30

Free Windows Admin Tool Kit Click here and download it now
November 26th, 2012 5:01am

Hi Suu30,

Please re-check endeka's response. We can modify the "href" property to redirect the page to a custom user profile page. We can construct the Url as Matthew did.

Thanks,
Jinchun Chen

November 26th, 2012 7:51am

Thanks,

But where exactly the changes should be done?

I mean is it in the XSL for the core result web part or any where else?

Please help...

Regards

Suu30

Free Windows Admin Tool Kit Click here and download it now
November 26th, 2012 9:47am

Yes, the XSL of the core result web part.

  1. Edit Webpart
  2. Display Properties
  3. Uncheck "User Location Visualization"
  4. Then click "XSL Editor"

Thanks,
Jinchun Chen

November 26th, 2012 9:49am

Hi,

I am sending the href to be written there...please check and revert back if any changes required

<a href="http://inceweb/_layouts/ince.searchparts/peopledetails.aspx?person={$username}','{preferredname} - {$username"}" id="{concat($currentId, '_CSR_IMGL')}" title="{preferredname}">

Please reply

Thanks

Suu30

Free Windows Admin Tool Kit Click here and download it now
November 26th, 2012 9:54am

The href value needs to contain the URL of you're custom page for displaying people details.
November 26th, 2012 10:17am

Hi Sucharita,

A little changed:

<a href="http://inceweb/_layouts/ince.searchparts/peopledetails.aspx?person={$username}" id="{concat($currentId, '_CSR_IMGL')}" title="{preferredname}">

Please replace "http://inceweb/_layouts/ince.searchparts/peopledetails.aspx?person=" with yours.

Per my testing, I am sure it works.

Thanks,
Jinchun Chen

Free Windows Admin Tool Kit Click here and download it now
November 28th, 2012 2:41am

Hi

How to change the user photo from different website based on emp Id or any any field value? For example

<img id="{$imgid}" src="{concat('http://myapp/IA_IMAGES/Employee%20Pics/', $empid, '.jpg')}" onError="this.src='/_layouts/images/o14_person_placeholder_96.png';" alt="{preferredname}" border="0"></img>

Is this something possible? Can any of you please respond, its bit urgent?

August 7th, 2015 2:49pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics