Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Option to display gender on Comment

2»

Answers

  • Options

    422 said:
    Best keep it to one question per thread

    haha ,thx,i will take it

  • Options

    A thought.

    If the gender data is hanging around in the user object at time of posting wouldn't it be more efficient to make another field for gender in the posts table and save it with the post?

  • Options
    x00x00 MVP
    Answer ✓

    The efficient solution is to cache the users, and join them pragmatically which is what JoinUsers does. Only it doesn't carry the gender across even though all the values are returned from the query.

    look in dashboard/models/class.usermodel.php -> JoinUser

    set the line to

    $Join = GetValue('Join', $Options, array('Name', 'Email', 'Photo', 'Gender'));

    This isn't the idea solution but it is simple for you, the plugin version would be more complex becuase there isn't a hook where you can add additional values in the mix, maybe somethign you can mention on github.

    grep is your friend.

  • Options
    x00x00 MVP
    edited May 2012 Answer ✓

    If the comment model Get added the the options, then you could use BeforeGet to to set $Options['Join'] retrieve what you want and go it by hooks, unfortunately the is not the case right now.

    grep is your friend.

  • Options
    peregrineperegrine MVP
    edited May 2012

    x00 (aka Obi-Wan Kenobi )said:

    The efficient solution is to cache the users, and join them pragmatically which is what JoinUsers does. Only it doesn't carry the gender across even though all the values are returned from the query.

    look in dashboard/models/class.usermodel.php -> JoinUser
    
    set the line to
    <pre>
    $Join = GetValue('Join', $Options, array('Name', 'Email', 'Photo', 'Gender'));
    </pre>
    

    >

    Thx xOO - Figured you would find an efficient solution for an inefficient one. I tested your change above and added:

      echo UserAnchor($Author);
      echo "Gender: $Author->Gender";
      

    and it worked my fine.

    X00 said:

    This isn't the idea solution but it is simple for you, the plugin version would be more complex becuase there isn't a hook where you can add additional values in the mix, maybe somethign you can mention on github.

    If the comment model Get added the the options, then you could use BeforeGet to to set $Options['Join'] retrieve what you want and go it by hooks, unfortunately the is not the case right now.>

    @sarowlwp - maybe you can add what he said... hint hint. Since you got your solution.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    422422 Developer MVP

    Does beg the question, this would be a nice feature for the dashboard ?

    There was an error rendering this rich post.

  • Options
    ToddTodd Chief Product Officer Vanilla Staff

    Even though Gdn::UserModel()->JoinUsers() doesn't join the Gender into the result table you don't need to.

    If you make a call to Gdn::UserModel()->GetID() after join users has been called and that user was already joined then the user will be cached in Gdn::UserModel() and it won't hit the database again.

  • Options

    good point it is already cached.

    Gdn::UserModel()->GetID($Author)->Gender

    grep is your friend.

  • Options

    x00 said:
    good point it is already cached.

    Gdn::UserModel()->GetID($Author)->Gender

    should be

    Gdn::UserModel()->GetID($Author->UserID)->Gender

    grep is your friend.

Sign In or Register to comment.