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.

'In This Discussion' user avatars not using Gravatar

2»

Answers

  • AoleeAolee Hobbyist & Coder ✭✭

    badlearner said:
    How to show Avatars (Photo / Gravatar) of Users participating in a discussion?

    [1] First enable the 'In This Discussion' and 'Gravatar' plugins on your forum

    [2] Open '/vanilla-forum-root/plugins/VanillaInThisDiscussion/class.inthisdiscussionmodule.php' and replace this block of code:

     public function ToString() {
        if ($this->_UserData->NumRows() == 0)
           return '';
        
        $String = '';
        ob_start();
        ?>
        <div class="Box">
           <h4><?php echo T('In this Discussion'); ?></h4>
           <ul class="PanelInfo">
           <?php
           foreach ($this->_UserData->Result() as $User) {
              ?>
              <li>
                 <strong><?php
                    echo UserAnchor($User, 'UserLink');
                 ?></strong>
                 <?php
                    echo Gdn_Format::Date($User->DateLastActive);
                 ?>
              </li>
              <?php
           }
           ?>
           </ul>
        </div>
        <?php
        $String = ob_get_contents();
        @ob_end_clean();
        return $String;
     }
    

    With this:

     public function ToString() {
        if ($this->_UserData->NumRows() == 0)
           return '';
        
        $String = '';
        ob_start();
        ?>
        <div class="Box">
           <h4><?php echo T('In this Discussion'); ?></h4>
           <div class="PhotoGrid">
           <?php
           foreach ($this->_UserData->Result() as $User) {
              echo UserPhoto($User);
              }
              ?>
           </div>
        </div>
        <?php
        $String = ob_get_contents();
        @ob_end_clean();
        return $String;
     }
    

    You've thereby modding the 'In This Discussion' plugin to output user avatar (the photo he uploaded to your forum, and if he hasn't, his Gravatar) instead of the username and date.

    [3] Now in the same file, change this line:

             ->Select('u.UserID, u.Name, u.Photo')
    

    to this:

             ->Select('u.UserID, u.Name, u.Photo, u.Email')
    

    That's it. And now your discussions should show something like this in the panel (sidebar) — the image below shows that 2 users are participating in the discussion:

    ![http://i.imgur.com/ftWQe.png]

    Happy modding! All credit to peregrine.

    @peregrine : Thanks for your time. :)

    that's the missing attribute "u.Email". :)



    Check out my other Plugins here

  • @Aolee : I don't understand. I don't see anything missing. ('u.Email' is there in the 3rd instruction. see?)

  • AoleeAolee Hobbyist & Coder ✭✭
    edited March 2012

    badlearner said:
    @Aolee : I don't understand. I don't see anything missing. ('u.Email' is there in the 3rd instruction. see?)

    nothing wrong with your mod. :) what i mean was the missing attribute i mentioned before was the Email. Email is needed by the Gravatar to work, same thing i encountered before in modding the whosonline to show the avatar. :) good job! :)



    Check out my other Plugins here

  • Oh, okay. Got it.

  • peregrineperegrine MVP
    edited March 2012

    @Aolee - please don't take offense....

    I know there are some brilliant people on this discussionboard and some trying to earn a buck, nothing wrong with that. And it can be tiresome for long time users to answer the same old questions that are exact duplicated questions (because somebody failed to search for the question or read the documentation). At times you may want the questioner to do a little work, so they will learn. But sometimes it is just as easy and perhaps better to provide the answer without making it a cryptic riddle. It can be a teaching tool and just as useful to provide newcomers some detailed answers. So pardon my vent, I just had to get this off my mind and I hope I don't insult anybody. Just want to add my thoughts for this specific situation. A constructive critique if you will. But let me preface it that you did provide some help and clues which is better than silence, but then that's why they call this a forum.

    case in point http://vanillaforums.org/discussion/comment/156272#Comment_156272

    "are you using any other plugin that's using the UserPhoto Function?"
    you could have also given a learning experience by teaching saying grep -r UserPhoto *
    in the vanilla directory to find a file where it is located and list the file name.

    "indexphotos?"

    ""check the content of the $User"
    you could have said var_dump($User), and you will notice there is no email value,
    it needs to be added.

    "and compare it to the $User of the one u edited in inthisdiscussionmodule.php"
    you could have said we need to put the e-mail in the object you can do this by adding it to the
    Select('u.UserID, u.Name, u.Photo, u.Email'). We know it is available from theuser table in the vanilla database by using phpmyadmin and browse the structure of the database, that is why we are adding u for user in u.Email.

    "there might be a missing attribute."
    yep, there might be - but you could have said there is a missing attribute it is called email.

    Also check out the whosonline plugin for an example of how I did it.


    leave the koans for the zen buddhists and the cryptic riddles for Oedipus to solve when the sphinx poses a riddle.

    I personally think it could benefit the whole user community and the addition of alot of useful plugins, if one were to step through ideas, provide an explanation, give some documentation before instead of after as a followup.

    Personally, I think the documentation badlearner provided is more useful and a better learning tool than a cryptic answer. Oh well, I've upset and alienated alll the people who could give me answers and help me :)

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

  • UnderDogUnderDog MVP
    edited March 2012

    peregrine said:
    @Aolee - please don't take offense....

    I know there are some brilliant people on this discussionboard and some trying to earn a buck, nothing wrong with that. And it can be tiresome for long time users to answer the same old questions that are exact duplicated questions (because somebody failed to search for the question or read the documentation). At times you may want the questioner to do a little work, so they will learn.

    As a fellow-forum-user I'm saying:
    That's a good start.

    But sometimes it is just as easy and perhaps better to provide the answer without making it a cryptic riddle. It can be a teaching tool and just as useful to provide newcomers some detailed answers. So pardon my vent, I just had to get this off my mind and I hope I don't insult anybody. Just want to add my thoughts for this specific situation. A constructive critique if you will. But let me preface it that you did provide some help and clues which is better than silence, but then that's why they call this a forum.

    As a fellow-forum-user I'm saying:
    Actually, you don't want to ask the brilliant programmers to explain the cryptic riddle. (That's my Opinion). You want the semi-programmers and documentation-writing-happy users to write documentation about those riddles.

    Don't we have the Vanilla Wiki to make that documentation now?

    http://vanillawiki.homebrewforums.net/index.php/Main_Page
    (If @hbf needs more help, just let us know)

    if one were to step through ideas, provide an explanation, give some documentation before instead of after as a followup.

    Can you give some examples of what you mean?

    Personally, I think the documentation badlearner provided is more useful and a better learning tool than a cryptic answer. Oh well, I've upset and alienated alll the people who could give me answers and help me :)

    Good, a new documentation specialist is born (documentalist, good word?)

    There was an error rendering this rich post.

  • AoleeAolee Hobbyist & Coder ✭✭

    no worries no offense taken.

Sign In or Register to comment.