Option to display gender on Comment
sarowlwp
New
i found one post about
Option to display gender on user profile page
http://vanillaforums.org/discussion/comment/143606/#Comment_143606
but i want display it on the comment ?
anyone can help ?
Best Answers
-
UnderDog
MVP
422 said:
Whos @423 ?A new version of @422 once he runs out of energy to post answers to silly questions :-|
sarowlwp said:
my question: i want display gender info on Comment Meta , i have done it in the profile page, but i can` get gender form discussion page , so any idea ?Show the exact code that you did on the profile page. Place it in < pre > tags or < code > tags or something else that makes the code readable.
1 -
x00
MVP
nah
that is very inefficient to query each person in a loop.
$Author->Gendernot work becuase in user model JoinUsers$Join = GetValue('Join', $Options, array('Name', 'Email', 'Photo'));is missing 'Gender'
You could add it, though not the most transportable solution.
0 -
x00
MVP
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.
1 -
x00
MVP
If the comment model Get added the the options, then you could use
BeforeGetto to set$Options['Join']retrieve what you want and go it by hooks, unfortunately the is not the case right now.0
Answers
Can you not mention me on every post you make?!
ok,just , i konw you are an active dev for vanilla .
sorry to trouble you
Saro, the way I see it is that lots of 'regulars' on this forum will 'read' all topics (with new posts in my case) so you do not have to mention the 'regulars', because they'll read it anyways.
What you need to do a little more is first try the option (for example from the discussion you found) and then write down what didn't work.
You can say : I want a red door, but all I found was a blue door. Or you can say : I want a red door, I have the red paint, but could not find the right brushes. All the stores are closed, what to do?
Do you see my point?
thx
got it
thx for you two . i will take your advice .
my question: i want display gender info on Comment Meta , i have done it in the profile page, but i can` get gender form discussion page , so any idea ?
Whos @423 ?
A new version of @422 once he runs out of energy to post answers to silly questions :-|
Show the exact code that you did on the profile page. Place it in < pre > tags or < code > tags or something else that makes the code readable.
Now i know how 006 felt about Roger Moore
I thought that was Dudley Moore.
he's one better.
@sarowlwp post your code, and the results. I'm sure one of the 'guys' will be able to point you in the right direction. I think this is the sort of specificity that underdog was aiming for.. but he's a lot more subtle than i am.
oh, and im both offended and grateful that you didn't @ me on this. (not an invitation, just trying for humor)
thx , i will change it , not @ anyone in the forum , you guys are nice ,sorry to trouble you all
here my code
file : views/discussion/helper_functions.php
function WriteComment($Object, $Sender, $Session, $CurrentOffset) { $Alt = ($CurrentOffset % 2) != 0; $Author = UserBuilder($Object, 'Insert');<li class="<?php echo $CssClass; ?>" id="<?php echo $Id; ?>"> <div class="Comment"> <div class="Meta"> <?php $Sender->FireEvent('BeforeCommentMeta'); ?> <span class="Author"> <?php echo UserPhoto($Author); echo UserAnchor($Author);i want inser gender info here and
echo $Author->Gender;not work
doesnt echo ($this->User->Gender); work ?
Fatal error: Using $this when not in object context in /home/aiqingda/www/www/themes/aiqingda/views/discussion/helper_functions.php on line 52
How have you got it working elsewhere?
<li class="<?php echo $CssClass; ?>" id="<?php echo $Id; ?>"> <div class="Comment"> <div class="Meta"> <?php $Sender->FireEvent('BeforeCommentMeta'); ?> <span class="Author"> <?php echo UserPhoto($Author); echo UserAnchor($Author); echo ($this->User->Gender);There may be a better way but this works. - but it will do a database read on every comment.
apparently it is Null in the $Sender, and $Object. I don't know if this is possibly a bug in the vanilla code or not.
you have to pull it out of the database yourself like below:
echo UserPhoto($Author); echo UserAnchor($Author); $AuthGender = Gdn::Database()->SQL()->Select('Gender')->From('User')->Where('UserID', $Author->UserID)->Get()->FirstRow(); echo $AuthGender->Gender;let us know if it works for you
nah
that is very inefficient to query each person in a loop.
$Author->Gendernot work becuase in user model JoinUsers$Join = GetValue('Join', $Options, array('Name', 'Email', 'Photo'));is missing 'Gender'
You could add it, though not the most transportable solution.
thx you ! which source file it is ?
thx you ! which source file it is ?> peregrine said:
thx, i have think about it , worried about mysql server, cost too much resource
Addtion Question: any one konw about php HTML staticstic , i mean generate html file for most not change page , so speed up the forums ,and cost less resource ~
Best keep it to one question per thread