Download & Extend

How to show comments on Profile Page

Project:Content Profile
Version:6.x-1.0-beta1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hi, I can see the comments after clicking on "View" on the Account Page, but how I can let Drupal show also the Comments on my normal Account Page? I tried so much out, please help me!

Comments

#1

Hi, so far I found out this has to be programmed. First I thought my programming skills are not enough, but now I am working on a module that is exactly doing that.

#2

Hi marenz. I was wondering if your module has been completed...

#3

Component:User interface» Miscellaneous

you can not show the comments unless the profile is set to full content AND takes over the profile, apparently...it's a bit odd in terms of user experience, but perhaps this should go in as a feature request...?

#4

Any more info on this one? I've got the same problem.

#5

I have the same problem... :-(

Maybe the best option is to set the Don't display this content profile on the user account page option and use your own profile template and call directly to

<?php
comment_render
($nid, $cid=0)
?>
to show de comments.

Anyway the problem persists if you access the node using ?q=node/XX (sometimes the VIEW link still points there...)
This module seems too problematic I think I'll try the guestbook module instead.

*UPDATE*
Well, after trying Guestbook, maybe the best integrated option is Content Profile... so I'll try to make my own profile template...
I still don't know what to do to avoid the ?q=node/XX link....

#6

I basically created a block 'view' of my comments, embedded that, and then called the comment form.

I put this in my node-profile.tpl.php page:

<?php
  
print views_embed_view(guestbook, $display_id = 'block_1', $nid);
   print
drupal_get_form('comment_form', array('nid' => $nid));
  
$node->comment = NULL;
   }
  
?>

#7

I have found this documentation in the author's blog.

Theming with content profile

When you have a "profile-as-nodes" you probably want to use some profile information stored in your profile content in some of your themes, e.g. to show some additional information about the author of a forum post. To do so, you previously had to manually load the profile node in your theme and output the right data at the right place - yeah and not forget to properly check your data...
This cried for improvements, so I tackled this problem. We need to be able to easily access the data of the created profiles, where it should be already properly prepared for use in a template so you haven't to check it yourself. Yes and we should do that fast.. So just loading all profile data and putting it into $user is really no option.

The solution I came up with is $content_profile: A little nice variable which is available in templates related to users that let's you access all the information stored in profiles. The nice thing is that it offers you all variables you are used to have a in a "node template" and it lazy-loads the profile content nodes - so they aren't loaded for nothing.

This is an example use you could put in a template to show the profile content's title:

<?php
echo $content_profile->get_variable('profile', 'title');
?>

For more, check out the README.txt which ships with the module.

#8

But that has nothing to do with showing comments, does it?

#9

Yes it has. For example, here is my solution:

  • Set Don't display this content profile on the user account page from admin options.
  • Edit user-profile.tpl.php from you template folder and add this wherever you want

    <?php
      $node
    = NULL;
     
    $node_profile = $content_profile->get_variables('profile');
      if(
    $node_profile)
       
    $node = &$node_profile['node'];

     
    // [ ... ]


      // This is the ready-for-print variable for the user profile data
     
    print $user_profile;

     
    // [ ... ]

      // Print this wherever you want to show the node_profile content
     
    print node_view($node, FALSE/*teaser*/, TRUE, TRUE);

     
    // [ ... ]

      // Put this where you want to show your comment block
     
    if ($node && function_exists('comment_render')){
        if(
    $node->comment)
        {
          print
    comment_render($node);
        }
      }
    ?>
  • you can overwrite the node-profile.tpl.php file to show you profile content themed.
  • Remember to clear cache if you have added new tpl files.
  • With this method you don't have to use the content_profile-display-view.tpl.php file and you have to access the profile using the user/XX query (not the node/XX query).

Hope it helps.

#10

#9 - I cant get that working! Can you advise what I might be doing wrong? I followed your instructions - but no comments are printed or ability to add comments. I am so confused. I am using Drupal 6.x.
The only part I couldn't see where to go to was "Set Don't display this content profile on the user account page from admin options." Where is this?

#11

I assume you are using content profile module
You should see this option in admin/content/node-type/%type%/profile

#12

Birwil, do you mean: "Use this content type as a content profile for users"? I followed your steps, but i get this error:
warning: Invalid argument supplied for foreach() in /usr/home/deb23581/domains/dezeil.nl/public_html/drupal/sites/all/modules/cck/content.module on line 1284.

#13

sorry I'm not using CCK... :-(

#14

it works for the core comment module. any suggestion for node comment showing in the content profile?
I try to embed view of node comment view -defaults using veiw_get_view and print, but doesnot work.

#15

I have been looking for something like this for some time now. Does the module you were creating functioning?

Regards,
chi hair straightener

#16

To show comments on the profile page.

Step 1: Edit the Profile content type:
- Enable comments, and set whatever settings you like. I like my comments 'Flat' and to hide subject lines.
- Select: Use this content type as a content profile for users
- Save

Step 2: Override the theme template file.

- Locate the content-profile-display-view.tpl.php in the Content profile module directory. Copy this into your theme directory.
- Open your theme's copy of content-profile-display-view.tpl.php. Add this code to the bottom:

<?php if ($node && function_exists('comment_render')){
    if(
$node->comment)
    {
      print
comment_render($node);
    }
  }
 
?>

- Clear your theme registry

This puts the comments on your profile page. Just tried this yesterday!

#17

Confirming that Heather's solution work's great. Thanks Heather.

I am working on a site where I need to create a Facebook style (sort of) "wall" -- trying to do just using Drupal core commenting (to keep things simple) -- comments on user profiles more or less does that.

I also used the suggestion here: http://drupal.org/node/661572#comment-2411118 so that when hitting the profile node directly it redirects you to the user page. Without that, if you post a comment to a profile in a user page, it redirects you to the profile node, when really you want to come back to the user page.

I wanted the user page to be a users "home page" (not the profile node) because that is the page that is linked to from so many places (such as 'author' link on posts).

#18

subscribe

#19

hi Rick, did you find the solution for staying on the page after submitting the comment?

#21

subscribing either

#22

in node-profile.tpl.php add these lines of code:

<?php
   
// We don't ever want to go to the nodeprofile itself.
    // Always redirect to the user page.
   
if (arg(0) == "node") {
   
drupal_goto("user/$node->uid", NULL, NULL, 301);
    }
   
?>
nobody click here