consolidation is great. I feel my site would be better served with fewer links and more content per page. Is there, or could there possibly be, a way to attach the guestbook directly to the user page rather than linking through "recent guestbook entries?"

CommentFileSizeAuthor
#19 guestbook_list_in_user_profile.patch6.91 KBmoonray
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

neablo’s picture

That's exactly what I need!

Is it possible to help me with a phptemplate file that integrates a guestbook directly in the user profile page?
That would be so great, I just don't know how to do it myself!

Is there anyone who is able to make such (as I think) difficult stuff?!?

Anonymous’s picture

Yes, I am looking to do this too!

I would imagine it can be done through the userprofile.tpl.php file, but how is the question. I am not much of a coder so perhaps we can get someone to help us out with this request.

Thanks in advance.

hba’s picture

Assigned: Unassigned » hba

Would this demand changes outside the guestbook module?

bluecobalt’s picture

See http://drupal.org/node/46976

It works for me.

peace,
blue

hba’s picture

Version: 4.6.x-1.x-dev » 4.7.x-1.x-dev

Bumping version to 4.7. Someone might have a hack for 4.7 as well?

scroogie’s picture

Yes, I did it already. Its really simple. You need a template override for your user_profile. An explenation for general profile customization can be found here: http://drupal.org/node/35728
To show the user guestbook just type

print module_invoke('guestbook', 'page', $user->uid)

in the profile template.
There is one problem though, and thats the reason i was just searching the issues. The problem is that you get forwarded to the dedicated guestbook page after submitting an entry. It would be nice if you could change the module, so that it uses an hidden form field to determine from which page it gets called, and redirects to this page after submission. The regarding code is in guestbook_form_entry_submit() line 407.

kylehase’s picture

So far looks good but the submission form is missing on my profile pages. Any ideas? Also, the theming for the guestbook module seems strange. I sometimes get white sections in the guestbook entry borders as if there's something wrong with the floating pictures. I'm ok with PHP but very new to CSS.

kylehase’s picture

Oops, disregard that issue about missing the form. I was looking at my own profile. Still have a theming issue though.

kylehase’s picture

Also found that if the user disables their guestbook, you get a "page not found" page where the guestbook should be. Any suggestions on an "if" statement to check thta the user has guestbook enabled?

kylehase’s picture

This seems to work but if anyone could suggest a better alternative please let me know.

<?php
if(!$user->guestbook_status){  // guestbook_status seems to store 0 for enabled and 1 for disabled
      print module_invoke('guestbook', 'page', $user->uid) 
}
?>
scroogie’s picture

 if module_exist('guestbook')
 {
   print module_invoke('guestbook', 'page', $user->uid)
 }
moshe weitzman’s picture

yes, seems like inline presentation of comments is the usual. i agree that guestbook should behave like this by default.

hba’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Status: Active » Fixed

added this info to INSTALL.txt in cvs

netentropy’s picture

cannot get the snippet to work in 5.1 added

<?php
if module_exist('guestbook')
{
print module_invoke('guestbook', 'page', $user->uid)
}
?>

as a cut and paste to a functional user profile overide and recieved the following error.

Parse error: syntax error, unexpected T_STRING, expecting '

on the second line of the code.

hba’s picture

Try this instead (added missing ";" and used module_exists() instead):

<?php
if module_exists('guestbook') {
    print module_invoke('guestbook', 'page', $user->uid);
}
?>
hba’s picture

Status: Fixed » Active
rayvan’s picture

Assigned: hba » rayvan
Category: feature » support
Priority: Normal » Critical
Status: Active » Postponed (maintainer needs more info)

so i put

 function phptemplate_user_profile($user, $fields = array()) 
 {  if module_exists('guestbook') { print module_invoke('guestbook', 'page', $user->uid);
  }
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
  }

in my template.php file????? please clarify.

jeforma’s picture

I have tried all the ways, and your modification to add the guestbook to the profile page does not work.

please help :)

Regards,

Charles

moonray’s picture

Assigned: rayvan » moonray
Category: support » feature
Status: Postponed (maintainer needs more info) » Needs review
FileSize
6.91 KB

After trying the option suggested in the INSTALL.txt I found several issues.
All the links still point to the guestbook/* url, instead of the user/* url.

So, I wrote up a patch that adds a configuration option to show the guestbook on the user profile page. It then fixes the links so the user profile page is the main page it always returns to, rather than guestbook/*.

Please review.

artycul’s picture

hey moonray...

absolutely great idea. i tried your patch and had only one problem... i couldn't get the comments to work properly. the diff around line 638 looks good for me, but when i click on 'add comment' the profile shows up as before (without guestbook_form_comment_form), while the url says something like: "www.domain.tld/user/2/comment/22#comment-entry". i had to change the file by hand, because the patch didn't work for me. i'm using the dev-version...

thanks
...sebi

moonray’s picture

Sounds like it could be a cache issue. Have you tried clearing your cache after applying the patch?
Also sounds like the patch needs to be re-rolled... will get to that soon.

artycul’s picture

sorry, clearing the cache did not solve the prob... i'll try to re-change the file from the original one and keep you informed to rule out mistakes by me ;) thanks again for the good work!

...sebi

hade’s picture

on my drupal 5.1 site all above snippets gave errors or "page not found" when a user disables his guestbook, now this works for me:

 if (module_exists('guestbook')) {
  if(!$user->guestbook_status){  // guestbook_status seems to store 0 for enabled and 1 for disabled
     print module_invoke('guestbook', 'page', $user->uid);
  }
 }

with moonray´s patch it´s nearly perfect, but now looking for some ajax functionality for guestbook pager on profiles. ;)

gurukripa’s picture

hi
i am using the Core profile module without any template override..

how can i ensure that the guestbook shows at the bottom of each profile...can this be done without a template override...

if i do have to do an override..then its going to be tough to get all the info back on the page...

can someone help me out..thanks..

gurukripa’s picture

Version: 5.x-1.x-dev » 5.x-1.0

i am using Version 5.x-1.0 not the dev verssion..pls help..thanks.

gurukripa’s picture

moonray..i want to use your patch..but u say u r going to re roll it..and also there was a point ..that there was some issue with comments....cld u clarify...
shld i use the patch ???

moonray’s picture

Version: 5.x-1.0 » 5.x-1.x-dev

I just checked, and there were no changes in 5.x-1.x-dev. So no need to re-roll.
Try applying it, and if it doesn't work we'll try and figure it out.

G Gavitt’s picture

I had the same problem as #20 (submitted by sebi_tl)

I did a quick fix by changing this line in moonray's patch

$comment_link = "user/$uid/comment/{$entry['id']}"; 

To

$comment_link = "guestbook/$uid/comment/{$entry['id']}";

That brings you back to the regular guestbook page when you add a comment back to a guestbook entry..I am not sure if the patch was supposed to add the comment form right on the profile page? That would be cool but, either way works for me ..YMMV.

scarer’s picture

Hi,

I tried to run the patch using the patch command in ssh and it returns an error that all 9 hunks failed.

Is there something I am doing wrong? Please help.

Sarah

panis’s picture

Title: option for adding guestbook to user page » Ajax functionality for guest book available

I just finished extended guestbook module to insert the guestbook in a block on any page

Features:
- show a clipped entry in the block - so if the entry is too long it will show the first "N" a teaser if you like.
- enter a new short entry into the guestbook - can be as long as you need but because it is a block I kept the entry to one line.
- Update the block using ajax as soon as the entry is updated - if ajax not available then the entire page will reload
- refresh block periodically and automatically only if ajax is available.

Configurations:
- adjust the height of the block and have scrollbar if needed
- change the background image of the block
- Limit the number of entries shown in the block

I will have a demo on my website later this week. Please let me know if something like this would be acceptable as part of the guestbook module or I should be developing an independent module. Any ideas and suggestions for features are welcome.

thanks

Muslim guy’s picture

Title: Ajax functionality for guest book available » Summary for custom userprofile (4.7.x and 5.x)

Please could somebody summarize here `How to integrate Guestbook with custom userprofile.tpl.php'

and add to `Fun with user_profile.tpl.php - stuff for MySpace or Friendster like customizable profile'

http://drupal.org/node/165114

*You'd be an instant Drupal hero to all Drupal users/non-programmers thank you :)

Muslim guy’s picture

Wow that worked! So simple, and no addition to template.php

So for 4.7.x, you must not use module_exists bcos its not understood by Drupal

  if(!$user->guestbook_status){  // guestbook_status seems to store 0 for enabled and 1 for disabled
     print module_invoke('guestbook', 'page', $user->uid);
  }
Muslim guy’s picture

The above for Drupal 4.7.x worked, only that when SUBMIT, you are brought to the actual guestbook, and you have to hit Back Button on your web browser to return to the custom user profile

Nice though, thanks a lot

*I also tried the lengthy PHP code from http://drupal.org/node/46976 but got wacky result

artycul’s picture

Thx Suede Pudding, with your help it now works for me, too ;)

JohnFilipstad’s picture

The problem with the code for 5.x stated above is that whenever the owner of the profile visits his own profile, Drupal seems to think that the profile has been edited and updated. This will show on userlists with last updated info or if you have snippets to show when the profileuser updated his profile.

dunno if it has the same problem in the 4.7.x snippet above. Haven't tested it.

72dpi’s picture

Does anyone know if you can add an entry to your own Gusetbook?
I am using it as 'comment blocks" on user pages, and it is handy to respond top someones comments.

Also, I would lofve to modify this, so U could have a 'whisper", whereby only you and the person you wrote on can read it.

Anyone thought of this? would be really handy...

sdsheridan’s picture

I could definitely use something like this. Is it ready for general consumption?

gurukripa’s picture

where can we see this..hope it works for Drupal 5.1

panis’s picture

Title: Display guestbook entries in user profile » Summary for custom userprofile (4.7.x and 5.x)
Component: Code » User interface
Assigned: Unassigned » moonray
Priority: Normal » Critical
Status: Needs work » Needs review

Comment removed...

sun’s picture

Title: Summary for custom userprofile (4.7.x and 5.x) » Display guestbook entries in user profile
Component: User interface » Code
Assigned: moonray » Unassigned
Priority: Critical » Normal
Status: Needs review » Needs work

@panis: If you want to share your code, please open a separate issue and attach a patch against the latest development snapshot of guestbook.

Setting a more appropriate title.

millions’s picture

Title: Summary for custom userprofile (4.7.x and 5.x) » Display guestbook entries in user profile
Component: User interface » Code
Assigned: moonray » Unassigned
Priority: Critical » Normal
Status: Needs review » Needs work

I'm sorry, where do you paste this code? I'm using the Denver theme and don't have a userprofile.tpl.php file or anything like that. can i paste it in my template.php like rayvan asked?

millions’s picture

I got it, I just need to resize the guestbook image and get it to use the imagecache pic. can't find how to do that.

the2ndday’s picture

Title: Display guestbook entries in user profile » use imagecache image for guestbook

I had same problem and I just changed guestbook module file(guestbook.module)
It's not pretty but, check it out.

What I did to use imagecache on guestbook page
Replace this code (from guestbook.module)
___________________
$picture = theme('image', $picture, $alt, $alt, '', false);
___________________
with this
___________________
$picture = theme('imagecache', 'Put name of imagecache profile you made', $account->picture, $alt, $alt, '', false);
___________________

sun’s picture

Title: use imagecache image for guestbook » Display guestbook entries in user profile

Please do not hijack issues.

fe’s picture

clicking the submit button brings me on the guestbook page, rather than the profile page. is there a fix? i really would appreciate this feature!!

IceCreamYou’s picture

Is there any chance of this patch getting into a release of the module anytime soon? If not, what needs to be done to get it in?

IceCreamYou’s picture

Also, how can I get the guestbook to display at the bottom of the user's profile instead of the top without reconstructing my profile page? I know it's possible (somehow) if I create a user_profile.tpl.php but I really don't want to have to go find all the different variables I need to put in it.

millions’s picture

I use advanced profile with panels. Then you can customize your profile layout easily.

IceCreamYou’s picture

I'll probably do that at some point, but working out all the theming procedures that Advanced Profile requires to make it look good is a little more than I have time for right now.

Muslim guy’s picture

The guestbook is sort of PUBLIC

So to achieve like u called `Whisper',

Akin to:
Private message :)

Modified privatemsg.module maybe?

coupet’s picture

subscribe

ChristieLuv’s picture

Hi! I tried all of the above with drupal version 5.7 but they seem to not be working. I'd like to try moonrays's patch but I don't have the capabilities to make patches. Can someone be so kind to attach the already patched file or is it even compatible with 5.7? I think an official release for 5.x would help so many people out. This is a feature a lot of people would want, a myspace style comment area. Thank you!

ChristieLuv’s picture

Yay! I got it to work with the code hade posted! I just needed to adjust some of my configurations. Thank you so much! My visitor profiles will be so much more fun now!

Carl Ditzler’s picture

Version: 5.x-1.x-dev » 6.x-1.0-rc1

Does someone have a fix to display guestbook within (not replace) user profiles for Drupal 6.x?

atuyo60’s picture

quam, isn't the guestbook already presented as a tab in the user page?

alexmoreno’s picture

is it possible to define the redirect url as #6 asked?

im using a user profile very optimized and i dont want to show the original template for the module

thanks in advance.

bflora’s picture

Version: 6.x-1.0-rc1 » 5.x-1.1

That looks like an easy hack. On line 519 of Guestbook 5.x.1.1 change

return 'guestbook/'. $uid;

to

return 'user/'. $uid;

seems to be working for me.

IceCreamYou’s picture

Do that also on line 581 and 620 for commenting and deletion to redirect to the profile page.

drupaloSa’s picture

For Drupal 6 use this code in user-profile.tpl.php file:

<?php
// $Id: user-profile.tpl.php,v 1.2.2.1 2008/10/15 13:52:04 dries Exp $

/**
 * @file user-profile.tpl.php
 * Default theme implementation to present all user profile data.
 *
 * This template is used when viewing a registered member's profile page,
 * e.g., example.com/user/123. 123 being the users ID.
 *
 * By default, all user profile data is printed out with the $user_profile
 * variable. If there is a need to break it up you can use $profile instead.
 * It is keyed to the name of each category or other data attached to the
 * account. If it is a category it will contain all the profile items. By
 * default $profile['summary'] is provided which contains data on the user's
 * history. Other data can be included by modules. $profile['user_picture'] is
 * available by default showing the account picture.
 *
 * Also keep in mind that profile items and their categories can be defined by
 * site administrators. They are also available within $profile. For example,
 * if a site is configured with a category of "contact" with
 * fields for of addresses, phone numbers and other related info, then doing a
 * straight print of $profile['contact'] will output everything in the
 * category. This is useful for altering source order and adding custom
 * markup for the group.
 *
 * To check for all available data within $profile, use the code below.
 *
 * @code
 *   print '<pre>'. check_plain(print_r($profile, 1)) .'</pre>';
 * @endcode
 *
 * @see user-profile-category.tpl.php
 *   Where the html is handled for the group.
 * @see user-profile-field.tpl.php
 *   Where the html is handled for each item in the group.
 *
 * Available variables:
 *   - $user_profile: All user profile data. Ready for print.
 *   - $profile: Keyed array of profile categories and their items or other data
 *     provided by modules.
 *
 * @see template_preprocess_user_profile()
 */
?>
<div class="profile">
  <?php print $user_profile; ?>
</div>

<?php
  if (module_exists('guestbook')) {
    if(!$account->guestbook_status){  // guestbook_status seems to store 0 for enabled and 1 for disabled
       print module_invoke('guestbook', 'page', $account);
    }
  }
?>
metazoid’s picture

In your code reloading the entire $account variable causes some pretty serious conflicts with other modules such as activity which thinks you've updated your profile every time you reload the page. Conversely if you use $account->uid to indicate a persons individual profile it gives a page no found error embedded into your user profile.

childfreecommunity_com’s picture

For Drupal 6.9 none of this worked...but here's what did...

I do a direct call to the function in guestbook.module that creates the guestbook page. Paste this code into your user-profile.tpl.php:

   if (module_exists('guestbook')) { 
      if(!$account->guestbook_status){  
         print guestbook_page($account, $op = NULL, $op_id = NULL, $page = TRUE);
      }
   }

It works beautifully and returns the user back to the profile page after posting. Anyone see any security or other issues with this?

samwich’s picture

I'm using Drupal 6.10 and guestbook 6.x-1.1 and couldn't get the above snippets to work,

I tried pasting the snippets into user-profile.tpl.php and my local site rendered a blank page. Ideally I would like to be able to paste this into my page-users.tpl.php page.

is there any chance someone could look into this?

jjesus’s picture

This code works in user-profile.tpl.php for Drupal 6.8 guestbook-6.x-1.1 :

  <?php
    if (module_exists('guestbook')) {
      $view_args = array($account);
      $func_args = array_merge(array('guestbook', 'page'), $view_args);
      $guestbook = call_user_func_array('module_invoke', $func_args);
      print $guestbook;
    }
  ?>
andrenoronha’s picture

how can I create a link to the user's guestbook in a custom block?

andrenoronha’s picture

i arranged that.

now, how can I add the number of new guestbook entries beside this link?

sumitk’s picture

to add guestbook block in profiles add this custom code

Copy paste this code in "Add custom content" with type php as filter

<?php
    if (module_exists('guestbook')) {
      $account_user = user_load(arg(1));
      $view_args = array($account_user);
      $func_args = array_merge(array('guestbook', 'page'), $view_args);
      $guestbook = call_user_func_array('module_invoke', $func_args);
      print $guestbook;
    }
  ?>
Thoor’s picture

Version: 5.x-1.1 » 6.x-2.x-dev

This code in #66 works fine for me. But only when the guestbook is activated in the user profile.

If not activated by the user in its profile, the profile-page is not shown correctly, with using the code.

Because of my PHP Lack, i am not able to inclue another "IF" for checking the activated Guestbook in Profile ...

andrenoronha’s picture

@ THOOR

you can:

if (!$account_user->guestbook_status) {
//yada yada if guestbook is active;
}

note:

0 => guestbook activated
1 => guestbook not activated

i dont know why it's not the opposite...

IceCreamYou’s picture

To clarify,

  if (module_exists('guestbook')) {
    $account_user = user_load(arg(1));
    if (!$account_user->guestbook_status) {
      $view_args = array($account_user);
      $func_args = array_merge(array('guestbook', 'page'), $view_args);
      $guestbook = call_user_func_array('module_invoke', $func_args);
      print $guestbook;
    }
  }

However, the Facebook-style Statuses module may be a better solution if you want to allow users to post messages on others' profiles, since it's designed to do that by default.

Thoor’s picture

Thx al lot for your help!

works like charme!

Thomas

Sinan Erdem’s picture

It works nicely... So I dont need a tab for the guestbook on users profile. Is there a way to remove it? (Other tnah using CSS)

Thanks,

Sinan

halloffame’s picture

Guys, all codes above lead you to the actual guestbook page after hitting the send button. What I want is that the user stays on the user profile page after submitting the guestbook entry. Any advice? Thanks.

andrenoronha’s picture

you can put a "?destination=user/[uid]" in the url of the link to the guestbook

Drupalskie’s picture

@ a.luiz.n

Where do i do that?

Greetings from Germany

andrenoronha’s picture

@Drupalskie

look for the function guestbook_entry in the guestbook module and implement it in your template.php file as yourtheme_guestbook_entry

dmf7’s picture

I'm really confused now after reading all of this. I don't know much about php but can't figure things out.
I installed the Guestbook module and I need it to display on my user profile pages. After a user posts a comment, i want it to stay on the profile page.

What code is the final working code for this and where does it need to be placed? Please help. if we alter one of the original files, will it get screwed up during an update?

Thanks,

frenk’s picture

Yes I'm confused to.

The code of IceCreamYou is working good, but it would be better to stay on the profile page after posting a guestbook entry.

How can I accomplish that?

frenk’s picture

Got it!

To get the guestbook on profile pages use this code of IceCreamYou in panels:

  if (module_exists('guestbook')) {
    $account_user = user_load(arg(1));
    if (!$account_user->guestbook_status) {
      $view_args = array($account_user);
      $func_args = array_merge(array('guestbook', 'page'), $view_args);
      $guestbook = call_user_func_array('module_invoke', $func_args);
      print $guestbook;
    }
  }

Then, to let posters stay on the profile page when posting a guestbook entry change the following code in guestbook.module:

Line 900

Change:
return 'user/'. $uid .'/guestbook';

In to:
return 'user/'. $uid .'';

quiptime’s picture

An new possibility exists to add the guestbook to the user profile (Content profile). You can use the Guestbook Views module to create an guestbook view and insert the view with Panels to the user profile.

dmf7’s picture

I downloaded guestbook views and am getting this error message after I add it to my user profile pane (when viewing user profiles).

user warning: Unknown column 'users.uid' in 'field list' query: SELECT guestbook.recipient AS recipient, users.uid AS users_uid, guestbook.author AS guestbook_author, guestbook.anonname AS guestbook_anonname, guestbook.message AS guestbook_message, guestbook.comment AS guestbook_comment, guestbook.commentauthor AS guestbook_commentauthor, (SELECT u.name AS commentauthor_name FROM users u WHERE u.uid = guestbook.commentauthor) AS guestbook_commentauthor_name, (SELECT u.name AS author_name FROM users u WHERE u.uid = guestbook.author) AS guestbook_entry_author_name, guestbook.created AS guestbook_created, ((SELECT LOCATE('guestbook_status";s:1:"1', u.data) FROM users u WHERE u.uid = users.uid) > 0) AS guestbook_status FROM guestbook guestbook WHERE (SELECT LOCATE('guestbook_status";s:1:"1', u.data) FROM users u WHERE u.uid = users.uid) > 0 LIMIT 0, 10 in /home/***/public_html/***/modules/views/includes/view.inc on line 771.

Does anyone know why I'm getting this message and how to fix it. Right now, the guestbook isnt displaying in the profile due to this error.

parasolx’s picture

#69 solve my problem. so it list out all the guestbook belongs to user.
nice code.