I tried to theme my user_pictures with a Imagefield in a profile.

After creating this user-picture.tpl.php :

  print $content_profile->get_variable('profile', 'field_userpicture');
  

i get the following error:
Fatal error: Call to a member function get_variable() on a non-object in /sites/all/themes/multiflex3/user-picture.tpl.php on line 21

Is the content-profile in this template not included? How do I theme user pictures?

Comments

Michelle’s picture

That will only work where the variable $content_profile is defined. Looks like it's not defined in that template.

Michelle

a.siebel’s picture

That's right.

I solved the problem manually:

My user-picture.tpl.php with imagecache support:

<div class="picture">

  <?php 
  $pict =  $content_profile->get_variable('profile', 'field_userpictures');
  $title =  $content_profile->get_variable('profile', 'title');
  print theme('imagecache','Thumbnail', "user_pictures/".check_plain($account->uid)."/".$pict[0]['filename'], $title, $title);
  

?>
(My user pictures are saved in user_pictures/uid )

In content_profile.module in line 558 i added the user_picture.tpl.php to the supported template functions

function content_profile_theme_registry_alter(&$items) {
  $templates = array_merge(array(
    'author_pane',
    'comment',
    'node',
    'page',
    'search_result',
    'username',
    'user_profile',
    'user_picture',
    'user_signature',
  ), variable_get('content_profile_extra_templates', array()));
DarrellHQ’s picture

So because you have to enable user picture support and pictures in post and comments for this to work it will also show an extra form on the user edit page. Anyway of getting around the whole thing and theming it to only use the field from content profile.

drumnjo’s picture

subscribing