Sage 9, Blade and Buddypress

blade
sage9

#1

Hi @smutek @MWDelaney
I’m trying to implement Buddypress with the latest dev-master of Sage 9.0.0-beta.3 (April 21st, 2017).
I’ve followed the various solutions here (Woocommerce & Blade (Sage 9)) to transpose it for Buddypress, without luck. Is there something new needed now that views are in resources/ ?
Here is explained how Buddypress template pack works:
Buddypress theme compat
I’ve tried to create a ‘buddypress’ folder in > resources/views/ buddypress/index.php with something like:
<?php echo App\Template('buddypress');
and, in ‘views’ folder i have created a file ‘buddypress.blade.php’ with this code:

@extends('layouts.app')

    @section('content')
      @while(have_posts()) @php(the_post())
        @include('partials.page-header')
        @include('partials.content-page')
      @endwhile
    @endsection

but it doesn’t work, any help will be much appreciate, because #buddypress is quite a major plugin in Wordpress world :eyeglasses:


Roots theme and buddypress
#2

When you say it “doesn’t work” what do you mean? What does it do? What doesn’t it do?

I also see that it seems you’re simply doing this

  @include('partials.page-header')
  @include('partials.content-page')

Which will include the Sage page header and content, not the BuddyPress content. What does the BuddyPress theming guide say should go here? For WooCommerce this is @php(woocommerce_content()).


#3

I dont think there is an equivalent for ‘woocommerce_content’ in Buddypress Template legacy. I thing BP use ‘the_content’ …
When i activate sage Theme with Buddypress i get a white screen of death and when WP_DEBUG in on true i dont have any php error or warning. Buddypress works with other wp themes on my wp install.

i have replace the code in buddypress.blade.php but it still doesn’t work:

@extends('layouts.base') 

@section('content') 
	@php(the_content())
@endsection

Here is how bp-legacy bp templates are organized:
buddypress GitHub

i think there is something to do with his templates php classes:
https://github.com/buddypress/BuddyPress/blob/master/src/bp-templates/bp-legacy/buddypress-functions.php

Any idea? Thanks for your help


#5

if i try to navigate to a “dynamic view” of buddypress (wth no corresponding wp page) i get a blank screen of death… If i create a ‘buddypress’ folder path the root level of Sage theme folder ‘resources’ with in a file called ‘buddypress.php’ with the following content
<?php echo App\Template('buddypress');

Than i dont have a blank screen and i’m able to display a page but without the buddypress content injected in it. That means buddypress template loader can’t find where to inject his content…

Now, I have managed to display the buddypress “members” page because the plugins settings allow to define a wp page for this “members” screen. If i select the default sage “Custom template” for this “members” page, i’m able to display the corresponding buddypress screen with no php error.

Now i’m stuck, any idea?


#6

Nevermind i have found the solution !

Here is how to make buddypress working withe Sage 9 blade template

  1. in your sage theme folder/ressources/
    Create a ‘buddypress’ folder

  2. in your new ressources/buddypress/ folder, create a file ‘buddypress.php’ with this in it :
    <?php echo App\Template('buddypress');

  3. in in your sage theme folder/ressources/views/
    Create a file called ‘buddypress.blade.php’ with this code in it :

    @extends(‘layouts.app’)

    @section(‘content’)
    @while(have_posts()) @php(the_post())
    @include(‘partials.page-header’)
    @include(‘partials.content-page’)
    @endwhile
    @endsection

Thats it, now Sage 9 is compatible with Buddypress
With this, you don’t have to change the default template for buddypress pages like ‘members’ or groups’ defined in wp admin Buddypress settings.

Hope that helps someone else!


#7

UPDATE

@MWDelaney
To enable buddypress template compatibility to Sage 9,
another (better) solution i use now is to add this filter to app/filters.php :

/**
 * change the default page template selection
 * needed for buddypress template compatibility
 */

add_filter('template_include', function ($template) {
    
    global $post;
    
    if (is_singular( 'page' )) {
        $default_template = locate_template( array( 'template-custom.blade.php' ) );
        if ( '' != $default_template 
            && '' == $post->page_template // Only when page_template is not set
        ){
            //return $default_template;
            $template = $default_template;
        }
    }

    return $template;
}, 99);

Hope it helps!


#8

A little less frightening of a solution:

add_filter('bp_template_include_theme_compat', function() {
    echo template('page');
    return '';
});

I personally use singular, but page should work out of the box for Sage. Unless you are using add_theme_support('buddypress')– BuddyPress just tries to override the_content() in anyway it can, so a generic page view should work as intended.