I’ve read all of the above and various solutions partly work but is there an official stance on how to integrate BuddyPress the correct way?
@Log1x - this solution works but any page that uses a custom
template shows up as a white screen …
add_filter('bp_template_include_theme_compat', function() {
echo template('page');
return '';
});
@mecanographik - this solution works but i have to list all my custom
page templates (which is not the end of the world of course!)
add_filter('template_include', function ($template) {
global $post;
if (is_singular( 'page' )) {
$default_template = locate_template( array( 'XXX.blade.php', 'YYY.blade.php' ) );
if ( '' != $default_template
&& '' == $post->page_template // Only when page_template is not set
){
//return $default_template;
$template = $default_template;
}
}
return $template;
}, 99);
The solution that works best is just adding a buddypress
folder to /resources/
, creating buddypress.php
and in it adding echo App\Template('buddypress');
and creating buddypress.blade.php
in /views/
- this works naively for all my scenarios.
The big issue i have now is that i can’t seem to target this template with any controllers. I create Controllers/BuddyPress
and i get an error about re-declaring a class. Even if i use echo App\Template('page');
in resources/buddypress/buddypress.php
- i can’t output from my Controllers/Page
either - it’s like the way I’ve implemented this doesn’t have any controller support (http://prntscr.com/o1hyyt)?
As an update - i’ve just added buddypress.blade.php
to that $default_template array = …
add_filter('template_include', function ($template) {
global $post;
if (is_singular( 'page' )) {
$default_template = locate_template( array( 'buddypress.blade.php' ) );
if ( '' != $default_template
&& '' == $post->page_template // Only when page_template is not set
){
//return $default_template;
$template = $default_template;
}
}
return $template;
}, 99);
… and i seem to have control now with my Page
controller!
So i seem to have stumbled across a solution - but i haven’t a clue what i’m doing to be honest! I’d really like to implement the ‘right’ way if anyone has figured it out?
Any help would be hugely appreciated.