Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Delegates for comments
judgej
✭
Not sure if this is the place for core requests or not, so move it if necessary.
I have created a plugin that allows an administrator to chose what name is displayed for each user, allowing the username (i.e. the login name) to be hidden. It does this by using delegate calls to overwrite the username (AuthUsername, LastUsername, Name, etc.) in the Discussion, Comments and User objects before they are displayed.
Now, there are delegate hooks for Discussions and Users, but none for Comments, so my request is that delegates are available for the pre-render points for individual comments.
Unlike the other two, the comments are not turned into objects before being passed to the theme. Instead, the raw database result set is sent to the theme, and the theme turns each row into an object.
I have added these two delegates to my theme, which works a treat. I would like to request that they (or something similar) are added to the core theme files in Vanilla:
1. themes/comments.php, just before $CommentList .= '<li:
2. search_results_comments.php, right at the start:
Of course, if delegates already exist and I am missing them, just say.
-- Jason
I have created a plugin that allows an administrator to chose what name is displayed for each user, allowing the username (i.e. the login name) to be hidden. It does this by using delegate calls to overwrite the username (AuthUsername, LastUsername, Name, etc.) in the Discussion, Comments and User objects before they are displayed.
Now, there are delegate hooks for Discussions and Users, but none for Comments, so my request is that delegates are available for the pre-render points for individual comments.
Unlike the other two, the comments are not turned into objects before being passed to the theme. Instead, the raw database result set is sent to the theme, and the theme turns each row into an object.
I have added these two delegates to my theme, which works a treat. I would like to request that they (or something similar) are added to the core theme files in Vanilla:
1. themes/comments.php, just before $CommentList .= '<li:
$this->DelegateParameters['Comment'] = &$Comment;
$this->CallDelegate('PreCommentRender');
2. search_results_comments.php, right at the start:
$this->DelegateParameters['Comment'] = &$Comment;
$this->CallDelegate('PreCommentRender');
Of course, if delegates already exist and I am missing them, just say.
-- Jason
0
This discussion has been closed.
Comments
"PreFormatPropertiesForDisplay"
Delegate, part of the"Comment"
Class. It should hook in just where you need it.library/Vanilla/Vanilla.Class.Comment.php @ 110
<?php $Context->AddToDelegate('Comment', 'PreFormatPropertiesForDisplay', 'ChangeUsernameToFullName'); function ChangeUsernameToFullName(&$Comment) { $Comment->AuthUsername = 'FirstName LastName'; }
I'm not sure how you're going to query for the Full Name though and it's late here so I need to sleep. That should get you started.
'FormatPropertiesForDisplay' is also very generic, and there appears to be a function for each of the objects - Discussions, Comments, Users etc. but only the Comments calls the delegate. I'm guessing the delegate function *could* have objects other than Comments passed to it in the future?
I wonder if there is a delegate for delegates? It would be nice to be able to stick a debug line in there to see exactly what delegates get called for each page view, perhaps through FireBug.
Updated plugin here: http://www.consil.co.uk/downloads/DisplayName.zip
-- Jason