I have a new Drupal 7 website with user profile pages like this one.

I'm new to Drupal and do not want to install any modules besides the core ones and the few written by me - because this will keep the site easy to maintain and upgrade for me at the beginning.

I have already written the 3 blocks displayed at my site's Triptych.

Now I'd like to add an image (will be a static Google map with a marker at user's city, for example: http://maps.google.com/maps/api/staticmap?sensor=false&markers=color:0x336699|Bern&&size=300x300 ) and a dynamic link to the user profile pages (i.e. the link depends on the user's id).

I.e. I know how to get user's city for my map:

$result = db_query('select field_city_value from {field_data_field_city} where entity_id=:uid', array(':uid' => array($viewer_id)));
$city   = $result->fetchField();

but I don't know how to extend the user profile page.

Please give me few hints on how to do it, which hook to use here and maybe few lines code.

And maybe anyone also knows how to add a Tab to a user profile page as well?

enter image description here

migrated from stackoverflow.com Mar 27 '11 at 8:56

This question came from our site for professional and enthusiast programmers.


For images, just enable the Image module and add an Image field to your users just like you already did with other fields.

For a link, assuming you want that to actually display it as a link and not just as text, I really suggest you have a look at http://drupal.org/project/link. I know you said you don't want any contrib modules but again, there is no reason to not do that. Drupal only really gets it's power from contributed modules. Upgrading minor versions is pretty much always trivial and Drupal 8 is most likely still years away and Drupal 7 will be supported until Drupal 9 is released, so you don't have to worry about that for quite some time. Using link.module will certainly be better than trying to develop your own module. link.module has already been tested on 2000 other D7 sites (and 70k D6 sites..).

The Tab question is something completely different, so I suggest you create a new question for that. For a start, you will need to implement hook_menu() and add a 'user/%user/something' menu item of type MENU_LOCAL_TASK.

  • Thank you Berdir, but I think adding an Image module won't help in my case. I want to display a google maps image with a marker at user's city (like: maps.google.com/maps/api/… ) And also the link is dependend on user's uid too - it will be a dynamic link to his game statistics: h1770839.stratoserver.net/user.php?id=DE8896 (BTW it is nice to read, what you've written about D7 stability, because I'm very conservative with my software/OS). – Alexander Farber Mar 9 '11 at 18:48
  • Ah. Yes, then you don't want to add an image to users, you want to add a location. The Google maps image is just how that information is displayed. There is a new module for Drupal 7 which offers this as a field, This might not be very stable yet but I'd suggest you try it out: drupal.org/project/geolocation – Berdir Mar 9 '11 at 18:58
  • BTW, I'm living near the city from your example image ;) – Berdir Mar 9 '11 at 19:01
  • Yeah, I guessed ;-) Thanks for answering my Drupal questions – Alexander Farber Mar 9 '11 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.