As it sounds. I'd like a section of my profile page to consist of user comments. Sort of for a field 'about [user]'... The comment form for it could be at the bottom of the profile just as normal comment forms would. I had thought of something like:

User Profile
-----------
[......]

About [user]
--comment1
--comment2
[...]

[......]

----------
comment form

I am already using a PHPtemplate for a customized profile page, so something in that direction should be easy.

Phil

Comments

filiptc’s picture

I have found a way to aproach the issue with the guestbook module and a php snipplet I found on this page.

I added the snipplet right in the middle of the page profile template:

$uid= arg(1);
  if (_guestbook_access('administer', $uid) && is_numeric($op_id)) {
    switch ($op) {
      case "delete":
       $y = guestbook_delete_entry_confirm($uid, $op_id);
      case 'comment':
        $comment_entry = $op_id;
        break;
    }
  }
// Fetch guestbook entries
  $userid4 = arg(1);
  $limit = variable_get('guestbook_entries_per_page', 20);
  $result = pager_query(
    "SELECT g.*, u1.name, u1.data, u1.picture, u2.name as commentby
    FROM {guestbook} g
    LEFT JOIN {users} u1 ON g.author = u1.uid
    LEFT JOIN {users} u2 ON g.commentauthor = u2.uid
    WHERE g.recipient = $userid4
    ORDER BY g.created DESC",
    $limit, 0, "SELECT COUNT(*) FROM {guestbook} WHERE recipient = %d", $userid4);
  $entries = array();
  while ($entry = db_fetch_array($result)) {
    $entries[] = $entry;
  }
  $output = theme('guestbook', $userid4, $entries, $comment_entry, $limit);
  print $output;

The problem I have now, is that I get the form right underneath the entries. I want it to be at the bottom of the page. I can't seem to find the way to dividing the snipplet... so I guess the guestbook.module just spits the whole thing out as one...

Am I right? Either way, how do I get the form part to display at the bottom?

Phil

filiptc’s picture

In case anyone wants to do anything similar on the profile node (or any other). I firstly installed the guestbook module and embedded the code above into the place of the phptemplate I wanted the user comments to appear. Then I opened up my guestbook.module in a text editor and removed or edited the parts I did not want to display or wanted to display differently. For instance, I wanted users to be forewarded to the profile node after submitting a comment, so I edited the 'guestbook/'. $uid, under the 'Insert new message' section, and changed it to 'user/1', being the profile from user 1. Then, instead of displaying the comment form at the bottom of the page I edited the guestbook preferences to display the form on a different page.

The final layout was something like this:

User Profile
-----------
[.......]

About User
>>add your description [link to form]
--comment 1
--comment 2
--[...]


[.......]
brakai295’s picture

I like that idea!!!

Could you tell me how/where i can format the guestbook entries? I would like to get rid of the user picture for example...

Would I have to do this in the guestbook.module or can this be done in the user_profile.tpl.php?

cheers,

kai

Webdesign Melbourne Australia
www.brizk.com

filiptc’s picture

If you'd like to get rid of the user picture on the user's profile you'd have to edit the user_profile.tpl.php, customizing the fields and removing the if($user->picture) {print theme('user_picture', $user);} snipplet.

Phil

brakai295’s picture

Hi filip!

thanks for your help. My member page looks really good now. One more thing I'd like to change though:

I have implemented a message that pops up at the top of the FRONT page and reads

"Welcome member name, there are 5 new entries in your guestbook! Go to your member page..."

I already found the code snippet that I need to display the number of unread messages:

if ($user->uid > 0 && _guestbook_exists($user->uid)) {
        $unread = _guestbook_newentries();
        $unread = $unread ? " (" . $unread . ")" : "";
       
      }
	  
	  print $unread

Now usually this number is reset to 0, when this member visits his own guestbook-page.

However, since the guestbook is on the member page itself, this doesn't work in our case. Do you have an idea how I can reset this number when the person visits his member page (rather than the guestbook)?

Cheers,
Kai

Webdesign Melbourne Australia
www.brizk.com

brakai295’s picture

has anyone else an idea please?

Kai

Webdesign Melbourne Australia
www.brizk.com

andygeorge’s picture

I looked in the module and found this code that records when you visted your guestbook. If you add it to the other guestbook coding in your custom profile page (user_profile.tpl.php), it will mark your guestbook as read whenever you view your profile:

  // Set last visited time for own guestbook
  if ($uid > 0 && $user->uid == $uid) {
    user_save($user, array('guestbook_visited' => time()));
  }

I've tested it, and it works as far as I can tell.

andygeorge’s picture

with further testing, it seems to work too well.
The alert seems to show up only some of the time, and clicking on any page seems to clear it.
Not sure why this would happen...
Hope this helps anyways

brakai295’s picture

hey,

thanks for your help. I haven't had a chance to test it, but what do you mean but "the alerts only seem to show up sometimes"? Does it return errors?

Cheers,

Kai

Webdesign Melbourne Australia
www.brizk.com

andygeorge’s picture

no, there weren't any error messsages. I meant the alert that tells you you have new messages didn't show up.
I think it had something to do with the way the $user variable was declared in the custom profile page (if I declared it as global $user, none of the profile fields would show up.)
The best solution I could find was to place the code into a block, and make it conditional so it only runs when you look at your own profile. So far I've found it to work:

  if (arg(0)=="user" && arg(1)==$user->uid) {
    user_save($user, array('guestbook_visited' => time()));
  }
brakai295’s picture

In a block?

mmh.. I'm getting more and more confused.

Is there a final solution for this issue now? If so, what exactly are the steps to achieve it!?
Cheers,
Kai

Webdesign Melbourne Australia
www.brizk.com

andygeorge’s picture

As far as I can tell, that fix works now.

I mean a block, as in a the blocks used for the content of sidebars and the navigation menu. You access it by (yoursite)/admin/blocks. If you create your own a block (admin/blocks/add), and then past the code I gave before (make sure the input type is PHP), then the new comments should be marked as read whenever a user vists their profile page (make sure the new block is enabled).
Hope that helps

brakai295’s picture

hey it seems to work! thanks a lot!! :-)

Webdesign Melbourne Australia - www.brizk.com
Work Travel Australien - www.ausmag.de

gurukripa’s picture

I found its hard to make a new template.php file..becoz so many modules link up to it..and its pretty difficult to add each item in a custom template file..

The second issue of putting Guestbook in the profile page is that if the person's guestbook is not enabled..then his/her profile page cannot be viewed...access denied or something like that..

so it would be nice to put the user Guestbook in a block on his/her page....

can someone give the code for this....such that it shows if enabled..else doesnt show.

thanks

My internet voluntary services include

1. Helping answer queries on www.krishna.com
2. Learning & Helping in the Vedic section of www.spiritualnectar.com
3. Helped in some aspects to make www.indiapoised.org
4. Learning & ( Helping newbies) on www.

andrenoronha’s picture

how can I display a message when the user guestbook is empty?
like: "you have no message"