[Guide] Discussion Thumbnail in FrontPage

AoleeAolee Hobbyist & Coder ✭✭
Update: There is now a plugin that does this. Also check out the Vanillicon indenticon plugin.

Hi Guys,

Just want to share with you on how i did the display of user thumbnails, who commented on each discussion title (in forum's frontpage), see demo here => http://www.pinoyau.info

There's still no plugin for this so, this guide is just a workaround.

affected files are the ff:

1. /applications/vanilla/views/discussions/helper_functions.php

Add the bold ones in the line: (note: pls correct the syntax of div tags (meaning remove the spaces on < / div > < div )

< div class="ItemContent Discussion">< div style="float:left;margin-right:10px;margin-top:5px;"><?php echo UserPhoto(is_null($Last->UserID)?$First:$Last); ?>< / div >< div >

And this line From:

$Sender->FireEvent('DiscussionMeta');
?>
< / div >
< / div >
< div style="clear:both">< /div>

< / div>


2. /plugins/Gravatar/default.php

Add is_null from the condition line: if ($User->Photo == '' && property_exists($Object, $Email)|| is_null($User->Photo)) {


3. /applications/vanilla/models/class.discussionmodel.php

Add the "->Select('lcu.Photo', '', 'LastPhoto')" in public function DiscussionSummaryQuery($AdditionalFields = array()) { after this line:

->Select('lcu.Name', '', 'LastName')
->Select('lcu.Photo', '', 'LastPhoto')
«1

Comments

  • yu_tangyu_tang New
    edited January 2011
    Thanks!
    I think it works better in combination with Identicon5 plugin.
    I'll do it.
  • AoleeAolee Hobbyist & Coder ✭✭
    edited February 2011
    addition to the code in step 3.

    ->Select('lcu.Name', '', 'LastName')
    ->Select('lcu.Photo', '', 'LastPhoto')
    ->Select('lcu.Email', '', 'LastEmail') //<-- last user's email <== gravatar encrypts the email and uses it as the id</b>
  • I hope to find this present in next Vanilla release.
  • edited February 2011
    this is great. can anyone make this a plugin for the moment?
  • thanks !!! It worked for me.
  • this is great, but instead of showing avatars i would like to use category icons. How can i do it?
  • I was looking for this! Thanks!
  • Thanks, but how to do avatars of authors of discussion? not avatar of recent user in discussion? please ansver me
  • thank you, it looks really nice now : http://www.herkesuzman.com
  • AoleeAolee Hobbyist & Coder ✭✭
    thank you, it looks really nice now : http://www.herkesuzman.com
    cool one you got there! :)
  • AoleeAolee Hobbyist & Coder ✭✭
    thank you, it looks really nice now : http://www.herkesuzman.com
    hi ntuyelik, may i ask how you did the tab thing?
  • AoleeAolee Hobbyist & Coder ✭✭
    Thanks, but how to do avatars of authors of discussion? not avatar of recent user in discussion? please ansver me
    try changing this line
    FROM
    <?php echo UserPhoto(is_null($Last->UserID)?$First:$Last); ?>
    TO
    <?php echo UserPhoto($First); ?>

    on file

    /applications/vanilla/views/discussions/helper_functions.php
  • try changing this line
    FROM
    <?php echo UserPhoto(is_null($Last->UserID)?$First:$Last); ?>
    TO
    <?php echo UserPhoto($First); ?>

    on file

    /applications/vanilla/views/discussions/helper_functions.php
    thanks, works, but avatars are too big on the front page, if they can be reduced from 50x50px to 32x32px?
  • AoleeAolee Hobbyist & Coder ✭✭
    you can either
    1. go to /applications/dashboard/design/style.css and modify
    div.mainthumb50 img {
    height: 50px; //32px
    width: 50px; //32px
    }

    or create a new css there like

    div.mainthumb32 img {
    height: 32px;
    width: 32px;
    }

    and change the class="mainthumb50" to class="mainthumb32" in /applications/vanilla/views/discussions/helper_functions.php
  • AoleeAolee Hobbyist & Coder ✭✭
    edited May 2011
    problem with 32x32 is ... if the title become 2liner long the next line pushes below the image.
  • thanks Aolee, everything works ok
  • AoleeAolee Hobbyist & Coder ✭✭
    np ;)
  • Hey I was unable to pull the first comment. The last comment works great...
  • AoleeAolee Hobbyist & Coder ✭✭
    edited July 2011
    do you want the first comment or the avatar of the person who created the thread?
Sign In or Register to comment.