possible to embed comments on my custom profile page (using node_load to get usernode fields)

Lausch - October 22, 2007 - 19:00
Project:Usernode Guestbook
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:MarcoR
Status:postponed (maintainer needs more info)
Description

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

#1

MarcoR - October 23, 2007 - 21:30
Status:active» postponed (maintainer needs more info)

What do you mean by custom profile page?

#2

Lausch - October 24, 2007 - 15:29

i mean by user_profile.tpl

<?php
print module_invoke('comment', 'nodeapi', $node, 'update index');
?>

show me the titles and comments but no template

i also tryd

<?php
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

#3

MarcoR - October 25, 2007 - 11:18
Assigned to:Anonymous» 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.

#4

Anonymous - November 12, 2007 - 22:42
Status:fixed» closed

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

#5

mariusooms - March 5, 2008 - 20:15
Status:closed» 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?

<?php
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

#6

mariusooms - March 5, 2008 - 21:35

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

In template.php

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

In user_profile.tpl.php

<?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?

#7

Lausch - March 5, 2008 - 22:18

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

#8

mariusooms - March 5, 2008 - 23:48

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:

<?php
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

#9

Lausch - March 6, 2008 - 02:15

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

#10

mariusooms - March 6, 2008 - 07:14

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:

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

#11

Lausch - March 6, 2008 - 19:34

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

#12

telefunken - May 25, 2008 - 00:37

i'm wondering what is the result!?

best regards
tf

#13

telefunken - August 27, 2008 - 00:21

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

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

 
 

Drupal is a registered trademark of Dries Buytaert.