hi guys,

is there a way to embed the comments to my custom profile page?

i use node_load to load fields of my usernode

anyway to show comments on my custom profile?

module_invoke or any possibilitie?

greets

Lausch

Comments

marcor’s picture

Status: Active » Postponed (maintainer needs more info)

What do you mean by custom profile page?

Lausch’s picture

i mean by user_profile.tpl

print module_invoke('comment', 'nodeapi', $node, 'update index');

show me the titles and comments but no template

i also tryd

print theme('comment_view', $node, module_invoke_all('comment', 'nodeapi', $node, 'update index'));

then i see the template from comment.tpl

but comment-cid and content will not work / shown

greets

Lausch

marcor’s picture

Assigned: Unassigned » marcor
Status: Postponed (maintainer needs more info) » Fixed

Thanks for your private message, that helped a lot!

Usually the usernode_guestbook is rendered inside a normal, untouched profile-page.

As I understood your local approach, you don't use this, because you load several nodes into into your custom styled user_profile.tpl.php

You can render the usernode's comment box if you use the function usernode_guestbook_box($account); where $account is the user object of the user whose profile page is to be displayed. Note: The API has changed, the function was called usernode_guestbook_usernode($account) until revision 1.2.

Please reopen this issue if you need further help on it.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

mariusooms’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

Sorry for reopening this, but what is the code I would use in my custom user_profile.tpl.php. Actually I would prefer to use it in a block if at all possible. This is what I posted in my template.php, is that correct to override the function?

function phptemplate_usernode_guestbook_box($account) {
  $node = usernode_get_node($account);
  $output  = '';
  switch ($node->comment) {
    case COMMENT_NODE_READ_WRITE: // 2
      $output .= comment_form_box(array('nid' => $node->nid), NULL);
    case COMMENT_NODE_READ_ONLY:  // 1
      $output .= comment_render($node);
      break;
    case COMMENT_NODE_DISABLED:   // 0
    default:
      $output .= t('@name\'s @guestbook is currently deactivated.', _usernode_guestbook_translations(check_plain($account->name)));
  }
  // Update the history table, stating that this user viewed the usernode.
  node_tag_new($node->nid);
  return $output;
}

Thanks for assisting,
Marius

mariusooms’s picture

I thought the following should work but it doesn't.

In template.php

function phptemplate_usernode_guestbook_box($account) {
	return _phptemplate_callback('usernode_guestbook_box', array('account' => $account));
}

In user_profile.tpl.php

print $account;

I'm kinda guessing how these theme overrides work, so it's no surprise it's not working. I really need to show the comments on my custom profile page with the comment post box. This module is exactly what I'm looking for, but without a solution for my profile page, I'm doomed. Any further help please?

Lausch’s picture

print $account huh?

use this my friend:


<?php print usernode_guestbook_box($user->uid) ?>

and if you want to add the usernode_guestbook into a custom node template use:


<?php print usernode_guestbook_box($node->uid) ?>

regards

Lausch

mariusooms’s picture

Thanks a ton Lausch...I have to admit, much of this php is abracadabra to me. So I took your code and together with the following line I stuffed it in a block like so:

global $user;
print usernode_guestbook_box($user->uid)

However that shows my comments on everybody's profile page, since I'm considered the current logged in user. What argument do I need to include to make it so it shows the users own comments?

Thanks in advance,
Marius

Lausch’s picture

just use ->


<?php print usernode_guestbook_box($user->uid) ?>

for guestbook on the profile tpl

and


<?php print usernode_guestbook_box($node->uid) ?>

on a node tpl

not global $user

regards

Lausch

mariusooms’s picture

Right...I failed to explain that without that line it fails to load the usernode guestbook properly for the user and returns "anonymous's guestbook is currently deactivated." So I used some code from another block and now it works perfect. Thanks for pointing me in the right direction. This is the added code to activate the user from a block:

$uid = arg(1);
$user = user_load(array('uid' => $uid));
print usernode_guestbook_box($user->uid)
Lausch’s picture

ok good! im happy that your snipped work...

but something...

$uid = arg(1);
$user = user_load(array('uid' => $uid));

you told me, you embed the guestbook on your custom profile template?

if you really use a custom profile tpl you have not use the function user_load()
$user is already defined.

try to print $user->uid bevor you use user_load and after, you have to get the same UID twice!

i think something is wrong in your template at another place.

your guestbook works ok, but just for your information, something seems wrong.

regards

Lausch

telefunken’s picture

i'm wondering what is the result!?

best regards
tf

telefunken’s picture

need help for the guestbook_block
i can write a comment, but the lines below the inputfield are not working/not collapsible...

$uid = arg(1);
$user = user_load(array('uid' => $uid));
print usernode_guestbook_box($user->uid)