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.

How to Replace "Most recent by" with Last Comment Excerpt

neyawnneyawn New
edited February 2012 in Vanilla 2.0 - 2.8

Currently below every discussion, the following is there:-

Most recent by #Last-Coment-UserID

I want to replace it by 10-20 characters from excerpts of the last comment made.
I am willing to edit the core for it.

Tagged:

Best Answer

  • x00x00 MVP
    Answer ✓

    Fist create you own locale in locales, using the skeleton for guidance. Don't name it en-CA or even a standard country code name it something like MyLocale (unique).

    then copy the definitions in applications/dashboard/locale/en-CA/definitions.php to your locale.

    substitute the values you have in config/locale.php in your locale.

    Add Most recent by %1$s definition

    grep is your friend.

Answers

  • Right now, I edited the /application/vanilla/model and commented

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

    This hides the userID of the person who made the last comment. But how do I get 10-20 character excerpts from the last comment in its place?

  • x00x00 MVP
    edited February 2012

    This is not a good strategy at all.

    First you don't know what what infrastructure/plugins relies on the LastCommentID. There is not reason to remove it from the model, it doesn't answer your question.

    Editing the core should be a last a resort, and only if you know what you are doing.

    First you need to read the documentation on creating plugins.

    There is already an excerpt plugin in the repository for help. You can adapt this.

    Note there is only so much help that can be offered in terms of programming, there is no point attempting plug-in like this without at least intermediate php knowledge.

    Note the discussion object in the view hook (inside loop e.g. AfterDiscussionTitle) does not contain the last comment body only the discussion body. It would not be efficient to query on every item, there is a reason why the LastCommetID is cached in the db rather than queried. You can query the Comment model (once per request) before rendering using the discussion ids for reference and cache the result in an id referenced array to be retrieved in the view hook.

    If you are still scratching your head I would walk away.

    You can strip the LastCommetID in the same view hook, also if you only want strip that the simplest way is to set in your locale

     $Definitions['Most recent by %1$s']='';
    

    grep is your friend.

  • I have tried this in my conf/locale.php

    While I have been able to translate most things like "Howdy" & "Start a Discussion", the above doesn't work for 'Most recent by'!

    Any idea why not? Yes, I have cleared my cache and refreshed my page.

  • x00x00 MVP
    Answer ✓

    Fist create you own locale in locales, using the skeleton for guidance. Don't name it en-CA or even a standard country code name it something like MyLocale (unique).

    then copy the definitions in applications/dashboard/locale/en-CA/definitions.php to your locale.

    substitute the values you have in config/locale.php in your locale.

    Add Most recent by %1$s definition

    grep is your friend.

  • Got it! Thanks

    Just a correction.

    $Definitions['Most recent by %1$s']='';

  • oops sorry, for the typo.

    grep is your friend.

Sign In or Register to comment.