Display guestbook entries in user profile
hipvictor - October 18, 2005 - 17:35
| Project: | Guestbook |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
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?"

#1
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?!?
#2
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.
#3
Would this demand changes outside the guestbook module?
#4
See http://drupal.org/node/46976
It works for me.
peace,
blue
#5
Bumping version to 4.7. Someone might have a hack for 4.7 as well?
#6
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
<?phpprint 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.
#7
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.
#8
Oops, disregard that issue about missing the form. I was looking at my own profile. Still have a theming issue though.
#9
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?
#10
This seems to work but if anyone could suggest a better alternative please let me know.
<?phpif(!$user->guestbook_status){ // guestbook_status seems to store 0 for enabled and 1 for disabled
print module_invoke('guestbook', 'page', $user->uid)
}
?>
#11
<?phpif module_exist('guestbook')
{
print module_invoke('guestbook', 'page', $user->uid)
}
?>
#12
yes, seems like inline presentation of comments is the usual. i agree that guestbook should behave like this by default.
#13
added this info to INSTALL.txt in cvs
#14
cannot get the snippet to work in 5.1 added
<?phpif module_exist('guestbook')
{
print module_invoke('guestbook', 'page', $user->uid)
}
?>
Parse error: syntax error, unexpected T_STRING, expecting '
on the second line of the code.
#15
Try this instead (added missing ";" and used module_exists() instead):
<?phpif module_exists('guestbook') {
print module_invoke('guestbook', 'page', $user->uid);
}
?>
#16
#17
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.
#18
I have tried all the ways, and your modification to add the guestbook to the profile page does not work.
please help :)
Regards,
Charles
#19
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.
#20
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
#21
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.
#22
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
#23
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:
<?phpif (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. ;)
#24
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..
#25
i am using Version 5.x-1.0 not the dev verssion..pls help..thanks.
#26
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 ???
#27
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.
#28
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.
#29
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
#30
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
#31
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 :)
#32
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
<?phpif(!$user->guestbook_status){ // guestbook_status seems to store 0 for enabled and 1 for disabled
print module_invoke('guestbook', 'page', $user->uid);
}
?>
#33
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
#34
Thx Suede Pudding, with your help it now works for me, too ;)
#35
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.
#36
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...
#37
I could definitely use something like this. Is it ready for general consumption?
#38
where can we see this..hope it works for Drupal 5.1
#39
Comment removed...
#40
@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.
#41
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?
#42
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.
#43
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);___________________
#44
Please do not hijack issues.
#45
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!!
#46
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?
#47
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.
#48
I use advanced profile with panels. Then you can customize your profile layout easily.
#49
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.
#50
The guestbook is sort of PUBLIC
So to achieve like u called `Whisper',
Akin to:
Private message :)
Modified privatemsg.module maybe?
#51
subscribe
#52
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!
#53
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!
#54
Does someone have a fix to display guestbook within (not replace) user profiles for Drupal 6.x?
#55
quam, isn't the guestbook already presented as a tab in the user page?
#56
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.
#57
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.
#58
Do that also on line 581 and 620 for commenting and deletion to redirect to the profile page.
#59
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);
}
}
?>
#60
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.
#61
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:
<?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?
#62
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?
#63
This code works in user-profile.tpl.php for Drupal 6.8 guestbook-6.x-1.1 :
<?phpif (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;
}
?>
#64
how can I create a link to the user's guestbook in a custom block?
#65
i arranged that.
now, how can I add the number of new guestbook entries beside this link?
#66
to add guestbook block in profiles add this custom code
Copy paste this code in "Add custom content" with type php as filter
<?phpif (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;
}
?>
#67
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 ...
#68
@ 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...
#69
To clarify,
<?phpif (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.
#70
Thx al lot for your help!
works like charme!
Thomas
#71
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
#72
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.
#73
you can put a "?destination=user/[uid]" in the url of the link to the guestbook