[buddypress-trac] [BuddyPress] #4639: Add template hierarchy support
buddypress-trac
noreply at wordpress.org
Wed Oct 31 22:45:29 UTC 2012
#4639: Add template hierarchy support
-------------------------+-----------------------------
Reporter: DJPaul | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Theme | Version:
Severity: normal | Keywords:
-------------------------+-----------------------------
Patch introduces a basic template hierarchy. Written based on feedback
from theme developers around 1.7's theme compatibility, and how they want
to use it.
WordPress' template hierarchy allows a default template to be overridden
based on the name of a page template, or category ID, or taxonomy slug,
and so on. BuddyPress doesn't let us do this. For example, if you wanted
to change the group-header.php template for a specific group, you need to
put a large conditional in the template. This is not ideal because the
template files become bigger, more complicated for designers to modify,
and because it doesn't match the WordPress way.
Some technical notes:
* I've commented out the bp_add_template_locations filter, because it was
misbehaving.
* I've changed the order of items in bp_get_template_locations, because we
are matching files in the `BuddyPress` directory inside bp-legacy before
overrides in the child/parent themes. This probably merits being patched
separately.
What does this patch let you do?
* User IDs can be suffixed to member templates.
* Group IDs can be suffixed to group templates.
* Group status types (private, public, protected, …) can be suffixed to
group templates.
* Activity types (new_blog, new_blog_comment) can be suffixed to activity
templates that are used INSIDE the activity loop.
Some examples:
* members/single/home-1.php has a higher priority (essentially) than
members/single/home.php for User ID = 1.
* groups/single/members-private.php has a higher priority than
groups/single/members.php for Private groups.
* activity/entry-new-blog-comment.php has a higher priority than
activity/entry.php for activity entries that are of the "new_blog_comment"
type.
About the activity hierarchy: we're overriding templates used inside the
activity loop because I see the situation as vaguely analogous to post
format templates in WordPress. We're not overriding templates used in the
groups loop (for example) because 1) there are many types of activity, 2)
only 3 types of groups, and 3) groups has many more templates which are
presented very differently from activity.
Feedback welcome.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4639>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list