Search code examples
drupaldrupal-blocks

Drupal: Access $profile from a block


I'm trying to get the avatar (profile picture) located in the $profile array to appear in a BLOCK. The variable $profile is not accessible from blocks. It's scope is only in that actual user-profile.tpl.php file. So... does anybody know how I can execute something like this:

print $profile[user_picture];

in a drupal BLOCK?


Solution

  • I figured i might as well post it here as well. See my second comment on the first thread in this discussion. Below is my code I used with INSERT VIEW to get what I wanted:

    <?php 
           $profileUser = "";
           if (arg(0) == "user") {
                $profileUser = arg(1);
           }
           // removed some other checks i do to populate $profileUser
    ?>
    
    [view:VIEWED_PROFILE_AVATAR=block=<?php print $profileUser; ?>]
    

    I hope that helps someone.