microsoft-search / pnp-modern-search

Home of PnP Modern Search solutions, helping you move from classic to modern SharePoint and beyond
https://microsoft-search.github.io/pnp-modern-search
Other
379 stars 337 forks source link

Turn off sections in Persona Cards #1168

Closed rdormanHW closed 1 year ago

rdormanHW commented 3 years ago

Version used 4.2.3

Question When using the hover persona cards as part of the Search Results web part, is there a way to turn off sections of the hover card from the display template? In particular I am looking to hide the Emails and Files sections as well as the Skills and Experience section

Screenshots image

Additional context My understanding is that MS provides the config object as part of MgtPersonCard to allow turning sections on and off similar to the code below:

import { MgtPersonCard } from @microsoft/mgt;

MgtPersonCard.config.useContactApis = false; MgtPersonCard.config.sections.profile = false;

But I don't want to change the underlaying web part so I can still easily apply updates from here. So is there any way through the existing web part to do this?

Is there anywhere in the template or configuration I can include this sort of code?

FranckyC commented 3 years ago

Hi @rdormanHW, unfortunately there is no easy way to disable these section. I didn't now about these properties. I'll flag it as an enhancement to expose them in the property pane configuration.

rdormanHW commented 3 years ago

Thanks. Can this property also be available for custom templates, not just the default People view? Adding custom attributes to a persona card is a common requirement for us and this can only be achieved currently through the custom display template. I don't mind if it is a property pane option, or something we can flag/pass in as part of the display template or configuration file.

wobba commented 3 years ago

@rdormanHW Customization of the OOB people card is achieved via the Graph API https://docs.microsoft.com/en-us/graph/api/resources/profilecardproperty?view=graph-rest-beta. If the graph toolkit will read these settings and adapt, then this can happen in the web parts as well. Anything people card is outside of this project.

rdormanHW commented 3 years ago

@wobba I'm not entirely sure I follow. According to this Microsoft documentation sections have to be turned off using JavaScript similar to the following:

import { MgtPersonCard } from @microsoft/mgt;

MgtPersonCard.config.useContactApis = false; MgtPersonCard.config.sections.profile = false;

Given I can't do JavaScript calls like this in the Handlebars template, where would I put this code? I am not asking you to change the web part. I just want to know if there is somewhere I can put this code so I can do it myself.

wobba commented 3 years ago

@rdormanHW there has to be a code change in the web part to support this. I was talking more about showing custom fields in the card, not sections - my mistake :)