Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#6486 closed defect (bug) (fixed)

'bp_template_title' h3 element should be more selectable/flexible

Reported by: boonebgorges Owned by: r-a-y
Milestone: 2.4 Priority: normal
Severity: normal Version: 1.2
Component: Templates Keywords: has-patch reporter-feedback commit
Cc:

Description

When using members/single/plugins.php to display custom component content, there's a bit of markup that looks like this:

<h3><?php do_action( 'bp_template_title' ) ?></h3>

To create a title for this kind of page, you add_action( 'bp_template_title', 'my_component_page_title' ); and echo your title.

Aside from being generally inelegant, this system poses problems for plugins that want to omit a title. If you don't hook anything to 'bp_template_title', you get an empty <h3></h3> element, which takes up vertical space. There's not even a great way to hide it using CSS, because it doesn't have any specific selectors.

I suggest first that we add a selector - something like class="bp-plugin-page-title". Better suggestions for selector names are welcome.

Better still, but more complicated: we should not show the <h3> element if there's nothing to put inside of it. Not sure how to do this without breaking backward compatibility. Maybe: fire 'bp_template_title' in an output buffer, and check its content before generating the markup.

Attachments (1)

6486.01.patch (581 bytes) - added by r-a-y 5 years ago.

Download all attachments as: .zip

Change History (13)

#1 follow-up: @r-a-y
5 years ago

We can check with has_action() perhaps before outputting.

Only problem is looking for the valid title callback for the page in question.

#2 in reply to: ↑ 1 @boonebgorges
5 years ago

Replying to r-a-y:

We can check with has_action() perhaps before outputting.

Good idea.

Only problem is looking for the valid title callback for the page in question.

In all my plugins, I only add_action() when I already know it's the right context. But maybe there are others that don't do this. If there are, then this can't be solved either with has_action() or output buffers. Phooey.

#3 @johnjamesjacoby
5 years ago

Either the markup should stay in the template and plugins should use custom template parts if need be, or we should build a title wrapper function that's also responsible for generating the markup, classes, etc...

@r-a-y
5 years ago

#4 @r-a-y
5 years ago

  • Keywords has-patch added
  • Version set to 1.2

01.patch uses the has_action() approach.

we should build a title wrapper function that's also responsible for generating the markup, classes, etc...

A wrapper function would be nice for plugins to replace the <h3> element with something else.

#5 @boonebgorges
5 years ago

#6547 was marked as a duplicate.

#6 @DJPaul
5 years ago

  • Keywords reporter-feedback added

Need to agree how to proceed with this.

This ticket was mentioned in Slack in #buddypress by boone. View the logs.


5 years ago

#8 @boonebgorges
5 years ago

  • Keywords commit added

01.patch is a definite improvement on what we currently have, and it requires minimal changes. Let's go with it.

#9 @r-a-y
5 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 10213:

bp-legacy: Output the title if one exists in the members plugins template part.

Previously, if a plugin wanted to omit the title from rendering, the
members plugins template part would still render an empty <h3> element;
this obviously isn't so great!

This commit now allows a plugin to omit the title as intended.

Fixes #6486.

This ticket was mentioned in Slack in #buddypress by boone. View the logs.


5 years ago

#11 @hnla
5 years ago

Just to note we have this same or similar issue with action buttons in areas like the groups headers which I've been puzzling over a solution for as it does interfere with layout sections. We could do with a generic approach to the do_actions where we don't wrap them in markup.

New ticket covering this: #6674

Last edited 5 years ago by hnla (previous) (diff)

#12 @DJPaul
4 years ago

  • Component changed from Appearance - Template Parts to Templates
Note: See TracTickets for help on using tickets.