Skip to content

Support for bp-default template overrides #5

@boonebgorges

Description

@boonebgorges

This is not so much a bug as a point for discussion.

infinity-cbox uses theme compat, which requires new-style, bp-legacy template overrides. These overrides differ from the old system (bp-default) in the following ways:

  1. bp-legacy templates are pulled from the template stack locations - by default, /buddypress/, /community/, or the infinity-cbox template stack location. bp-default templates are pulled from component directories in the root (/members/, /groups/, etc).
  2. bp-default top-level templates (generally called index.php or home.php) include calls to get_header(), get_footer(), get_sidebar(). These calls are absent in bp-legacy templates.
  3. Nested templates in bp-default use locate_template(). Nested templates in bp-legacy use bp_get_template_part().
  4. bp-legacy top-level templates include a <div id="buddypress"> wrapper.

If you currently have a cbox-theme child theme that overrides templates (using the bp-default system), here's what happens when you switch to the new cbox-theme:

a. Overridden templates like /members/index.php are properly found and loaded. (If you've got both /members/index.php and /buddypress/members/index.php, the latter takes precedence, which I think is good.)
b. Any templates nested within these overridden templates are not loaded, because the locate_template() call fails - item (3) above.
c. bp-default templates look funky, though, tbh, not as bad as I'd expect.

This is going to result in a moderate level of brokenness for these themes. Let's work out a strategy. There are some things we can do technically, and other things we should document.

Technically, we could detect when a bp-default template is being loaded, and when it is, do one or more of the following:

  • Noop the calls to get_header(), etc (see (2) above)
  • Dump the whole thing in an output buffer and wrap in <div id="buddypress">, to make sure styling and scripts still work (see (4) above)
  • Hook somewhere into locate_template() to redirect template lookups to the template stack (see (3) above)

I can imagine sinking a lot of time into this, and still not really getting it right - the pages are still going to look lousy, as at least some markup has changed in the bp-legacy templates. So, another technical strategy is to prevent BP from recognizing bp-default templates. Instead of having a messed-up site, custom themes would have a site that uses the bp-legacy/infinity-cbox templates, and perhaps we could show an admin notices letting admins know they'll need to migrate their templates over manually. (This seems more sane to me, but I'm curious what you guys think.)

In terms of documentation, it would be ideal to have documentation along these lines https://codex.buddypress.org/themes/theme-compatibility-1-7/bp-17-upgrading-template-packed-themes/, but more technically helpful - a brief walkthrough of an actual example (telling you to remove calls to get_header(), etc) would be nice.

@r-a-y @MrMaz Any thoughts about the above? Thanks in advance :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions