Skip to:
Content

BuddyPress.org

Opened 8 years ago

Closed 4 years ago

Last modified 4 years ago

#5153 closed enhancement (wontfix)

Add hooks to modify display of entire comment

Reported by: lchski Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Templates Keywords: needs-patch reporter-feedback
Cc:

Description

Currently the way comments are laid out, if someone were to want to modify the display of an entire comment (say, wrap it in a div), they'd have to hook into bp_before_activity_comment and bp_after_activity_comment.

The unfortunate side effect of this is that the entire comment would be wrapped in the div -- including all children (replies) of that comment.

This is not desirable behaviour, and it'd be great to have a hook that could be used to modify the content of just one comment, ignoring its children.

This would mean putting the first hook before .acomment-avatar, and the second hook after .accomment-options.

Thoughts? Could this be a suitable improvement. I'll work on the change if people are willing and believe it to be worthwhile.

Change History (7)

#1 @DJPaul
8 years ago

  • Component changed from Core to Theme
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 1.9

In the activity/comment.php template? Seems reasonable to me; naming the action names as "early" and "late" might make sense as a pattern to use for actions inside loops inside blocks of HTML.

How did you run into this problem? I assume if you want to hook it, you aren't working on a theme; are you building a plugin?... or are you building out a theme? :)

#2 @boonebgorges
8 years ago

The improvement sounds fine to me, though I'm not totally sure how you'll prevent the recursion issue with a simple hook. Happy to see a patch, though!

#3 @r-a-y
8 years ago

it'd be great to have a hook that could be used to modify the content of just one comment, ignoring its children.

If you are manipulating this with hooks, then I believe you can just check the current activity comment ID before doing your manipulation.

eg.

function my_add_div_to_specific_activity_comment() {

	// add a open <div> element if the activity comment ID equals 1
	if ( bp_get_activity_comment_id() == 1 ) {
		echo '<div>';
	}

}
add_action( 'bp_before_activity_comment', 'my_add_div_to_specific_activity_comment' );

You'll have to use the same logic when closing the <div> as well.

Let me know if this is enough to address your issue.


Although, I do agree with this:

This would mean putting the first hook before .acomment-avatar, and the second hook after .accomment-options.

These would have to be new hooks. We can't move existing hooks due to backwards-compatibility reasons.

#4 @boonebgorges
7 years ago

  • Keywords reporter-feedback added
  • Milestone changed from 1.9 to Future Release

Moving out of a specific milestone, pending reporter feedback.

#5 @DJPaul
5 years ago

  • Component changed from Appearance - Template Parts to Templates

#6 @DJPaul
4 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing most tickets related to BP-Default and BP-Legacy, since the upcoming BP-Nouveau template pack (planned for 3.0) will make these redundant.

#7 @DJPaul
4 years ago

Closing most tickets related to BP-Default and BP-Legacy, since the upcoming BP-Nouveau template pack (planned for 3.0) will make these redundant.

Note: See TracTickets for help on using tickets.