Add template hierarchy support
|Reported by:||DJPaul||Owned by:||boonebgorges|
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.
- 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.
Change History (61)
- Keywords commit added; dev-feedback removed
- Milestone changed from Awaiting Review to 1.7
comment:35 follow-up: ↓ 42 r-a-y — 16 months ago
comment:46 boonebgorges — 11 months ago
- Keywords commit removed
- Milestone changed from Future Release to 1.8