Hi,

I've created a new custom view mode for nodes, and it works great. My theme's templates named node--BUNDLE--VIEW-MODE.tpl.php are found and render exactly as I expect. However, I can't figure out how to get a template working for users. I've added the new view mode, defined user--user--VIEW-MODE.tpl.php, and cleared the cache, but it just doesn't seem to take. It _does_ render using the settings I set up through the UI, so certain fields are hidden and the ordering is what I want, but I need a little bit more control.

Is it possible to use templates for custom view modes on user entities? If so, what is the proper naming convention for the template files? If not, are there any workarounds you could suggest?

Thanks,
Noah

Comments

lex0r’s picture

Version: 7.x-1.0-beta3 » 7.x-1.0-rc1
Component: Documentation » Code
Category: support » feature

Subscribing.
At the moment it is user_profile theming function that prevents node-like view mode template suggestions. It is only possible to define view mode templates in this way:

// your theme's template.php
/**
 * Make it possible to have one user template file per view mode.
 */
function mytheme_preprocess_user_profile(&$vars) {
  $view_mode = $vars['elements']['#view_mode'];
  $vars['theme_hook_suggestions'][] = 'user_profile__' . $view_mode;
}

And you will have to name your templates like user-profile--viewmode-name.tpl.php.
This could be possibly moved to module's preprocess_user_profile.