ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Viewing ALL comments made by the author of an entry...

March 20, 2012 3:29pm

Subscribe [2]
  • #1 / Mar 20, 2012 3:29pm

    oliverhood

    17 posts

    Is there a way that I can show ALL the comments in a channel made by a the author of the current entry that the visitor is viewing.

    E.g. A visitor is viewing ‘Post A’, written by Member 1, is there a way of listing all the comments made by Member 1 in that or other channels?

    Hope that made some kind of sense.

  • #2 / Mar 20, 2012 5:36pm

    elative

    8 posts

    You should be able to accomplish this by using the “author_id” parameter. Try something like this on a single-entry page:

    {exp:comment:entries author_id="{author_id}"}
    <div id="comment-{comment_id}">{comment}</div>
    {/exp:comment:entries}

    Hope that helps point you in the right direction.

  • #3 / Mar 20, 2012 6:50pm

    oliverhood

    17 posts

    One step closer…

    It lists the comments a user has made, but I need to be able to link to the entry that comment was made about. I was hoping this would work:

    {exp:comment:entries author_id="{author_id}" dynamic="no"}
    <div class="comment-divider">
    <a href="http://{url_title_path=temps/profile}">{title}</a>
    </div>
    {/exp:comment:entries}

    But it just links back to the current entry and uses the current title.

    EDIT: I should also add that the template this is in is the temps/profile one, but I need to link to the other entries using the same template in the way described above.

  • #4 / Mar 20, 2012 9:27pm

    elative

    8 posts

    Try this if you’re open to a PHP solution:

    1. Inside the single-entry loop, assign the {author_id} tag to a variable (e.g. “$author_id”).
    2. Outside of the single-entry loop, do the following:

    {exp:channel:entries 
     channel="your_channel" 
     dynamic="no" 
     disable="categories|category_fields|member_data|pagination"}
     
     {exp:comment:entries entry_id="{entry_id}" author_id="<?= $author_id ?>"}
       <a href="http://{url_title_path=temps/profile}">{title}</a>
     {/exp:comment:entries} 
    {/exp:channel:entries}

    Also, take a look at {comment_url_title_auto_path}.

  • #5 / Mar 21, 2012 8:05am

    oliverhood

    17 posts

    Re: point 1, assigning the variable… how would I go about that? I take it is isn’t as simple as the old way of doing assign_variable and it’s tag?

    The rest I can do.

  • #6 / Mar 21, 2012 12:39pm

    elative

    8 posts

    In your single-entry loop, just do something like:

    <?php $author_id = '{author_id}'; ?>

    Also, for your template, make sure “Allow PHP” is set to “Yes” under the “Edit Preferences” menu on the Design > Templates > Template Manager page.

  • #7 / Mar 21, 2012 3:37pm

    Shane Eckert

    7174 posts

    Hello oliverhood,

    I am happy to see that you have had some help from elative. Thanks for the assist elative.

    Does this set you on the right path?

    Is there anything I can help you with?

    Just let me know!

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases