Profile Addon - Deleting Avatar Comments Help
DaPerson
New
Hey,
I'm developing an addon which allows users to delete avatar comments on their wall only.
The controller I found which renders the comments is ProfileController_BeforeActivity_Handler. Though I don't think there's a way to render the delete button without overriding some methods. I'm wondering if there's a better way to do this.
0
Comments
The ActivityComments list is rendered here:
<?php $Comments = val('Comments', $Activity, array()); if (count($Comments) > 0) { echo '<ul class="DataList ActivityComments">'; foreach ($Comments as $Comment) { WriteActivityComment($Comment, $Activity); } } else { echo '<ul class="DataList ActivityComments Hidden">'; }Each single comment is written with the writeActivityComment function:
if (!function_exists('WriteActivityComment')): function writeActivityComment($Comment, $Activity) { $Session = Gdn::session(); $Author = UserBuilder($Comment, 'Insert'); $PhotoAnchor = userPhoto($Author, 'Photo'); $CssClass = 'Item ActivityComment ActivityComment'; if ($PhotoAnchor != '') $CssClass .= ' HasPhoto'; ?> <li id="ActivityComment_<?php echo $Comment['ActivityCommentID']; ?>" class="<?php echo $CssClass; ?>"> <?php if ($PhotoAnchor != '') { ?> ...A delete button should look like that:
<div class="Options"><a href="/dashboard/activity/delete/XYZ/transientKey?Target=profile%2Fusername" class="Delete">×</a></div>You would have to add it right after the
li.ActivityCommentelement. Sadly, there is no event fired which could help you.I see only one obvious option, but there might be a second way to do so:
.Activity-PictureChange > .ActivityComments > .ActivityComment. The transientKey is available in your JavaScript with thisvar transientKey = gdn.definition('TransientKey');Although normally I'd prefer PHP solutions, the JavaScript way would be less invasive here and I would use it in this case.
Thank you so much! I'll probably go with the JS solution.