How to show comments on Profile Page

marenz - April 11, 2008 - 02:02
Project:Content Profile
Version:6.x-1.0-beta1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

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!

#1

marenz - April 13, 2008 - 15:37

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

Passionate_Lass - July 17, 2008 - 19:35

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

#3

zilla - October 26, 2008 - 19:25
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

peashooter - July 26, 2009 - 22:57

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

#5

birwel - August 21, 2009 - 16:45

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

peashooter - August 21, 2009 - 16:49

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

birwel - August 21, 2009 - 16:58

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

peashooter - August 23, 2009 - 10:03

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

#9

birwel - August 23, 2009 - 12:43

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

twopointoh - October 27, 2009 - 16:30

#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

birwel - October 29, 2009 - 19:02

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

#12

Sailingdude - November 10, 2009 - 20:23

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

birwel - November 13, 2009 - 18:02

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

 
 

Drupal is a registered trademark of Dries Buytaert.