[buddypress-trac] [BuddyPress] #4639: Add template hierarchy support

buddypress-trac noreply at wordpress.org
Fri Nov 9 20:59:42 UTC 2012


#4639: Add template hierarchy support
-------------------------+------------------
 Reporter:  DJPaul       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  1.7
Component:  Theme        |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  commit       |
-------------------------+------------------

Comment (by r-a-y):

 The settings templates are actually named that way because of a bug.  See
 #3582.

 I'm opposed to adding hierarchy for these when devs can use the more,
 flexible:
 `/members/single/home-settings.php` (when on the settings component and
 when the patch is committed)

 Chances are you'll want to style all the settings pages with the same
 outer template.

 ----

 '''Paul:''' With what we talked about last week, I spent some time testing
 everything again (except group extensions).

 I'm going to outline the problem
 [https://buddypress.trac.wordpress.org/ticket/4639#comment:33 noted by
 Roger above].

 == Problem ==

 I like theme compat, but want to override a template loaded
 `bp_core_load_template()`.

 Let's say I like theme compat and want to continue using theme compat, but
 want to merely add or change the markup to a template loaded by
 `bp_core_load_template()` (such as `/members/single/home.php`).

 '''A)''' If I move `/members/single/home.php` from bp-legacy over to my
 current theme (`wp-content/themes/twentytwelve/members/single/home.php`),
 `bp_core_load_template()` is loading this template before theme compat is
 executed:
 https://buddypress.trac.wordpress.org/browser/trunk/bp-core/bp-core-
 catchuri.php#L379
 https://buddypress.trac.wordpress.org/browser/trunk/bp-core/bp-core-
 catchuri.php#L398

 Therefore, I won't see get_header(), get_sidebar(), etc, because bp-
 legacy's home.php is just a template part.  It won't load the skeleton
 template from page.php (or any of the templates from
 `bp_get_theme_compat_templates()`).

 The problem is we're referring to home.php in two different use-cases.
 Both as a regular page template and a template part.

 '''B)''' If I move `/members/single/home.php` to my theme's subdirectory
 like `/buddypress/members/single/home.php` or
 `/community/members/single/home.php`, this works as expected.

 It's quite confusing and we're the implementors!


 == Proposed solution ==

 For template hierarchy, we should use `index.php` (or page.php, etc.) as
 our marker instead of `home.php`.

 Then, the hierarchy would look like this:

 {{{
 $templates = array(
         'members/single/index-' . $user_nicename . '.php',
         'members/single/index-' . $user_id       . '.php',
         'members/single/index-' . $component     . '.php',
         'members/single/index.php'
 );
 }}}

 This solves all problems with home.php disambiguation.

 As a reference point, we've already renamed templates in theme compat
 before; the registration templates in theme compat were renamed from
 `/registration/register.php` to `/members/register.php`.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4639#comment:35>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list