Hi there,
For project specific regions I needed to display a view of users which naturally have their profiles attached. Because of the nature of this view listing page, I was looking to have a sort of user teaser view mode active so I wouldn't get the full profile. Unfortunately even if I created a teaser view mode for users the full profile would still come through because there is no relationship there. I'm submitting a feature request to have profile entities inherit the view modes of their users. This addition will still allow profiles to be displayed on their own but will give admins much greater control on the display of user entities also (with profiles).
Comments
Comment #1
smithmilner CreditAttribution: smithmilner commentedThis is still a ways from complete but it works!
Comment #2
smithmilner CreditAttribution: smithmilner commentedI've found that view modes can be missing depending on profile2's order in the hook_entity_info_alter(). This is stab in the dark to try and get a final result on the user entity.
Comment #3
smithmilner CreditAttribution: smithmilner commentedhello?
Comment #4
fagoSounds good to me, the hack in the entity-info-alter hook is very ugly though. I think just inheriting the view-modes that are available during alter should do it - if someone adds one in after us, he can do it for profile2 too.
Comment #5
smithmilner CreditAttribution: smithmilner commentedOk, we'll go back to the first version of the patch to avoid ugly hackyness. Another small issue here is that users have a view mode called "full" which for all purposes is identical to profile2's view mode "account". After the profile2 inherits user view modes we end up with a duplicated view mode as seen in the second screenshot. I think it would be ideal to change the machine name of profile2's view mode to be "full" so it's inline with users. I haven't thought about what sort of implications that might have, what do you think?
user view modes: https://skitch.com/smithmilner/gc9au/welcome-to-participedia-participedia
profile2 view modes(after patch): https://skitch.com/smithmilner/gc9ab/welcome-to-participedia-participedia
Comment #6
langworthy CreditAttribution: langworthy commentedComment #8
smithmilner CreditAttribution: smithmilner commentedaha, editor renamed it to .txt. Let's try this again...
Comment #10
smithmilner CreditAttribution: smithmilner commentedRerolled against dev.
Comment #11
kevinquillen CreditAttribution: kevinquillen commentedThat patch worked for me! Went in circles for two hours on this.
Comment #12
fagoShould start capitalized and end with a point, in short it should be a full sentence.
This is changes the view-mode which is used by default, which might break people's settings.
Thus, we cannot change the default view-mode. Maybe just go with 'account' for view mode "full" and pass through others.
Comment #13
mpgeek CreditAttribution: mpgeek commentedHere is another version with a more general approach that takes into account the fact that default view mode for profile2 is
account
that is associated with thefull
view mode for user, as pointed out in #12. A more general approach would likely be to implement view modes along the lines of the way entity reference provides display mode configuration when attaching to another entity.Comment #14
Sophie.SKApplied the patch and it seems to be working for me - thanks! :)
Comment #15
RickJ CreditAttribution: RickJ commentedClosed as duplicate of #2148375: Displaying a profile with a specific view mode. The actual code fix is a one-liner, there is no need to map 'full' to 'account'.
If a view mode doesn't exist the display falls back to the default. The system displays the regular user account page using view mode 'account', but there is no need to preclude adding 'full' as another view mode for other purposes.