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.

[Solved] how to show the most recent comment?

2»

Answers

  • camocamo New
    edited October 2011
    5 minutes please, setting up your version again so you can see ok

    @Aolee ok now your version in place but not working
  • UnderDogUnderDog MVP
    Answer ✓
    How to change the bubble css too?
    @camo you need to figure out some stuff by yourself too man, Aolee did plenty by showing us guides and making plugins. Try something, if fails, try again, if then fails, you can say your tried (code) and tried (code) and then ask for some help.

    Of course you're trying these things at your localhost, right? Good! Turn on the debug SQL queries (search on the forum how to do that) and try + try to figure out which SQL query is executed on your local forum to retrieve those excerpts (CTRL-F will get you somewhere in your firefox browser)
    Then post that SQL that's executed and only the SQL you think is relevant.

    There was an error rendering this rich post.

  • camocamo New
    edited October 2011
    No, im doing all this on my actual site. Ive followed all aolee's instructions to the letter and I have shown here what ive done. I have no idea what your saying about debugging sql queries, none whatsoever, its all chinese to me.
    If you want me to just leave this be, just say so and I will revert to the original plugin.

    Everything in place, here is classdiscussionmodel.php

    still dosent work

    http://www.camosreptiles.com.au/forum/index.php?p=/
       public function DiscussionSummaryQuery($AdditionalFields = array(), $Join = TRUE) {
    // Verify permissions (restricting by category if necessary)
    if ($this->Watching)
    $Perms = CategoryModel::CategoryWatch();
    else
    $Perms = self::CategoryPermissions();
    if($Perms !== TRUE) {
    $this->SQL->WhereIn('d.CategoryID', $Perms);
    }

    // Buid main query
    $this->SQL
    ->Select('d.Type')
    ->Select('d.InsertUserID', '', 'FirstUserID')
    ->Select('d.DateInserted', '', 'FirstDate')
    ->Select('d.CountBookmarks')

    ->Select('d.Body') // <-- Need these for rss!
    ->Select('d.Format') // <-- Need these for rss!
    ->Select('d.DateLastComment', '', 'LastDate')
    ->Select('d.LastCommentUserID', '', 'LastUserID')
    ->From('Discussion d');

    if ($Join) {
    $this->SQL
    ->Select('iu.Name', '', 'FirstName') // <-- Need these for rss!
    ->Select('iu.Photo', '', 'FirstPhoto')
    ->Select('iu.Email', '', 'FirstEmail')
    ->Join('User iu', 'd.InsertUserID = iu.UserID', 'left') // First comment author is also the discussion insertuserid

    ->Select('lcu.Name', '', 'LastName')
    ->Select('lcu.Photo', '', 'LastPhoto')
    >Select('lc.Body','','LastUserComment')
    ->Select('lcu.Email', '', 'LastEmail')
    ->Join('User lcu', 'd.LastCommentUserID = lcu.UserID', 'left') // Last comment user
    ->Join('Comment lc', 'd.LastCommentID = lc.CommentID', 'left') // Last comment
    ->Select('ca.Name', '', 'Category')
    ->Select('ca.UrlCode', '', 'CategoryUrlCode')
    ->Select('ca.PermissionCategoryID')
    ->Join('Category ca', 'd.CategoryID = ca.CategoryID', 'left'); // Category

    }
  • Nevermind, Underdog is getting Anal again!

    @Aolee, thanks for your time.
  • AoleeAolee Hobbyist & Coder ✭✭
    edited October 2011
    ok i got it. use this

    public function DiscussionSummaryQuery($AdditionalFields = array(), $Join = TRUE) { // Verify permissions (restricting by category if necessary) if ($this->Watching) $Perms = CategoryModel::CategoryWatch(); else $Perms = self::CategoryPermissions(); if($Perms !== TRUE) { $this->SQL->WhereIn('d.CategoryID', $Perms); } // Buid main query $this->SQL ->Select('d.Type') ->Select('d.InsertUserID', '', 'FirstUserID') ->Select('d.DateInserted', '', 'FirstDate') ->Select('d.CountBookmarks') ->Select('d.Body') // <-- Need these for rss! ->Select('d.Format') // <-- Need these for rss! ->Select('d.Format') // <-- Need these for rss! ->Select('lc.Body','','LastUserComment') ->Select('d.DateLastComment', '', 'LastDate') ->Select('d.LastCommentUserID', '', 'LastUserID') ->From('Discussion d') ->Join('Comment lc', 'd.LastCommentID = lc.CommentID', 'left'); if ($Join) { $this->SQL ->Select('iu.Name', '', 'FirstName') // <-- Need these for rss! ->Select('iu.Photo', '', 'FirstPhoto') ->Select('iu.Email', '', 'FirstEmail') ->Join('User iu', 'd.InsertUserID = iu.UserID', 'left') // First comment author is also the discussion insertuserid ->Select('lcu.Name', '', 'LastName') ->Select('lcu.Photo', '', 'LastPhoto') ->Select('lcu.Email', '', 'LastEmail') ->Join('User lcu', 'd.LastCommentUserID = lcu.UserID', 'left') // Last comment user ->Select('ca.Name', '', 'Category') ->Select('ca.UrlCode', '', 'CategoryUrlCode') ->Select('ca.PermissionCategoryID') ->Join('Category ca', 'd.CategoryID = ca.CategoryID', 'left'); // Category } // Add any additional fields that were requested if(is_array($AdditionalFields)) { foreach($AdditionalFields as $Alias => $Field) { // See if a new table needs to be joined to the query. $TableAlias = explode('.', $Field); $TableAlias = $TableAlias[0]; if(array_key_exists($TableAlias, $Tables)) { $Join = $Tables[$TableAlias]; $this->SQL->Join($Join[0], $Join[1]); unset($Tables[$TableAlias]); } // Select the field. $this->SQL->Select($Field, '', is_numeric($Alias) ? '' : $Alias); } } $this->FireEvent('AfterDiscussionSummaryQuery'); }


    Actually UnderDog just want you to play more with vanilla code so you will be more familiar with it :) cheers!
  • :) vanilla code makes my head hurt! Thankyou Aolee, I will try this now.
  • camocamo New
    edited October 2011
    OK its now showing last comment but not last photo.

    http://www.camosreptiles.com.au/forum/
  • AoleeAolee Hobbyist & Coder ✭✭
    edited October 2011
    sorry that is a different one, i think you're using lincoln's IndexPhotos plugin, not sure how to tweak that one. mine is a direct hack again ^^ using an old vanilla version
  • camocamo New
    edited October 2011
    Oh ofcourse silly me. Thankyou so much for your time and patience, its working very well now! :)
    Thankyou Thankyou Aolee!

    Edit: I got that one tweaked, very easy! Woohoo! :)
  • camocamo New
    edited October 2011
    @Aolee

    was just testing possible conflicts between this plugin (your core hack)
    http://vanillaforums.org/discussion/comment/145182#Comment_145182

    and feed discussions, where p[ost in feeddiscussions were being truncated.

    I removed this file amnd uploaded the original from RC2 and did utility update and it still works! E.G still shows last comment in the excerpt. Strange no? :)

  • http://vanillaforums.org/discussion/comment/145182#Comment_145182

    was replaced with...

    public function DiscussionSummaryQuery($AdditionalFields = array(), $Join = TRUE) {
    // Verify permissions (restricting by category if necessary)
    if ($this->Watching)
    $Perms = CategoryModel::CategoryWatch();
    else
    $Perms = self::CategoryPermissions();
    if($Perms !== TRUE) {
    $this->SQL->WhereIn('d.CategoryID', $Perms);
    }

    // Buid main query
    $this->SQL
    ->Select('d.Type')
    ->Select('d.InsertUserID', '', 'FirstUserID')
    ->Select('d.DateInserted', '', 'FirstDate')
    ->Select('d.CountBookmarks')

    ->Select('d.Body') // <-- Need these for rss!
    ->Select('d.Format') // <-- Need these for rss!
    ->Select('d.DateLastComment', '', 'LastDate')
    ->Select('d.LastCommentUserID', '', 'LastUserID')
    ->From('Discussion d');

    if ($Join) {
    $this->SQL
    ->Select('iu.Name', '', 'FirstName') // <-- Need these for rss!
    ->Select('iu.Photo', '', 'FirstPhoto')
    ->Select('iu.Email', '', 'FirstEmail')
    ->Join('User iu', 'd.InsertUserID = iu.UserID', 'left') // First comment author is also the discussion insertuserid

    ->Select('lcu.Name', '', 'LastName')
    ->Select('lcu.Photo', '', 'LastPhoto')
    ->Select('lcu.Email', '', 'LastEmail')
    ->Join('User lcu', 'd.LastCommentUserID = lcu.UserID', 'left') // Last comment user

    ->Select('ca.Name', '', 'Category')
    ->Select('ca.UrlCode', '', 'CategoryUrlCode')
    ->Select('ca.PermissionCategoryID')
    ->Join('Category ca', 'd.CategoryID = ca.CategoryID', 'left'); // Category

    }

    // Add any additional fields that were requested
    if(is_array($AdditionalFields)) {
    foreach($AdditionalFields as $Alias => $Field) {
    // See if a new table needs to be joined to the query.
    $TableAlias = explode('.', $Field);
    $TableAlias = $TableAlias[0];
    if(array_key_exists($TableAlias, $Tables)) {
    $Join = $Tables[$TableAlias];
    $this->SQL->Join($Join[0], $Join[1]);
    unset($Tables[$TableAlias]);
    }

    // Select the field.
    $this->SQL->Select($Field, '', is_numeric($Alias) ? '' : $Alias);
    }
    }

    $this->FireEvent('AfterDiscussionSummaryQuery');
    }
Sign In or Register to comment.