How to Replace "Most recent by" with Last Comment Excerpt
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:
0
Best Answer
-
x00
MVP
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.phpto your locale.substitute the values you have in config/locale.php in your locale.
Add
Most recent by %1$sdefinitiongrep is your friend.
0
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?
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 theLastCommetIDis 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
LastCommetIDin the same view hook, also if you only want strip that the simplest way is to set in your localegrep 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.
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.phpto your locale.substitute the values you have in config/locale.php in your locale.
Add
Most recent by %1$sdefinitiongrep is your friend.
Got it! Thanks
Just a correction.
$Definition
s['Most recent by %1$s']='';oops sorry, for the typo.
grep is your friend.