I'm using Drupal on a site for short term missionaries. I'd like to have a short bio appear with each users blog overview, or if that doesn't work with each of their blog posts-- kind of like how they do it on blogger.com. I also like how it is done with the OG module where users create a description for the group. Thanks for any ideas.

Comments

adrian’s picture

Use phptemplate and populate the mission field with the user's biography (from his profile) when on a page such as 'blog/n' where n = user->uid.

--
The future is so Bryght, I have to wear shades.

tatonca’s picture

... if you aren't already using phptemplate, you could do the same thing in a custom block with the path set to <^blog\/([0-9]*)> This will give you a blogger style 'About Me' block...

Hrmmmm.... Oh well, I was meaning to do this anyway....

[goes away for 5 minutes]

[ok more like 10... ;) ]

<?php

  if (arg(0)=='blog' && is_numeric(arg(1))){
    $uid = arg(1);
    $account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1));
    profile_load_profile(&$account);
    
    echo("<div align=\"left\">");

    if (isset($account->realname)){
      echo("
        <b>Name:</b><br>
        $account->realname<br>
      ");
    }

    if (isset($account->country)){
      echo("
        <b>Location:</b><br>
        $account->country<br>
        <br>
      ");
    }

    if (isset($account->biography)){
      echo("
        <em>$account->biography</em><br>
        <br>
      ");
    }

    echo("
      </div>
      <div align=\"right\">
      <a href=\"http://www.blogtown.ca/user/$account->uid\">more</a>
      </div>
    ");

  }

?> 

Ok, you'll need to have profile.module on, that's given. The profile fields above may or may not be default, I don't remember, but you can put whatever fields you have there instead.

Last thing - where it says blogtown.ca - you need to change that to the base url of your website.

If some of this looks familiar, I was inspired by the random image block - thanks to the author of that for shining a light on the darkness...

Hopefully I haven't reinvented the wheel here, but I figure if the Bryght guy doesn't know of an easier already done way neither do I!! ;)

Now you have options...

Cheers

jasonwhat’s picture

Is there a way to keep this from appearing if the user hasn't put anything in their biograpy field?

adrian’s picture

Create a file called 'template.php' in your phptemplate template directory .. containing :

   function _phptemplate_variables($hook, $vars) {
     if ( (arg(0)=='blog') && is_numeric(arg(1)) && ($hook == 'page')){
        $uid = arg(1);
        $account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1));
        profile_load_profile(&$account);
        $vars['mission'] = isset($account->biography) ? $account->biography : null;
     }
     return $vars;
   }

--
The future is so Bryght, I have to wear shades.

tatonca’s picture

Isn't teamwork grand!? [shakes adrians hand]

ti’s picture

This is interesting.

jasonwhat’s picture

Thanks so much, this will be a big help. You are great. I will get working with this right away. What does the $vars['mission'] do? Total php novice here.