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.

EE2.13: conditionals not working in exp:comment entries

June 22, 2011 1:41am

Subscribe [1]
  • #1 / Jun 22, 2011 1:41am

    dsgreen

    40 posts

    I’m using 2.1.3 and experiencing variations of this bug. I was trying to use:

    {if avatar_url != ""}

    which did not work. But this works:

    {if avatar}

    No problem there, aside from the time wasted trying to solve the problem. A simple conditional should evaluate as expected.

    But, I’d like to apply a class based on the member group ID in the comments area. As in:

    {if member_group_id == 6}class="admin"{/if}

    This does not work, but testing for author_id does work. As in:

    {if author_id == 2}class="admin"{/if}

    Are there any updates on this bug?

    Edit: Adding a link to the original thread so this is in context.
    http://ellislab.com/forums/viewthread/174960/

  • #2 / Jun 22, 2011 1:03pm

    Kyle Cotter

    730 posts

    Hi Doug,

    Could you try using “member_group” instead of “member_group_id”?

    Check out Conditional Global Variables - Member Groups for more details.

    Hope you get this sorted out!

    Thanks.

  • #3 / Jun 22, 2011 1:18pm

    dsgreen

    40 posts

    Hi Kyle,

    Thanks for the suggestion. I just tried this, but all the commenters seem to have the same member group. When I output {member_group}, I get a “1” for everybody. When I output {member_goup_id}, I get the group ID I’m expecting for the members in a particular group. In this case, it’s an ID of “6”. The people that are not registered and just post a comment don’t have a group ID.

    So the member group ID would allow me to apply a class to comments from a specific group. The {member_group} doesn’t seem like it would work unfortunately.

    Doug

  • #4 / Jun 22, 2011 3:53pm

    dsgreen

    40 posts

    Well, testing for {group_id} works. I’m not sure why that works, and the others don’t. Don’t know if that is a bug or not.

    This seems to work for me:

    {exp:comment:entries channel="channel_1" paginate="bottom"}
          <div class="comment{if group_id == 6} author{/if}">
          etc…
    {/exp:comment:entries}
  • #5 / Jun 23, 2011 5:50pm

    Lisa Wess

    20502 posts

    Hi, dsgreen -

    What version are you in?  Working with EE 2.2.0, I put this code in a totally blank template:

    {exp:channel:entries channel="test" limit="10"}
    <h2><a href="http://{title_permalink=test/index}">{title}</a></h2>
    <p>{test}<br />
    {/exp:channel:entries}<br />
    {exp:comment:entries channel="test" sort="asc" limit="20"}<br />
    member_group_id: {member_group_id}</p>
    
    <p>{comment}<br />
    By {name} on {comment_date format="%Y %m %d"}<br />
    {/exp:comment:entries}

    and on the front-end parsing, I did in fact get:

    member_group_id: 1

    so it appears to be working in EE 2.2.

  • #6 / Jun 23, 2011 6:04pm

    dsgreen

    40 posts

    Hi Lisa, I’m using 2.1.3.

    Doug

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

ExpressionEngine News!

#eecms, #events, #releases