Hi folks,
[Apologies for posting here, but I can’t see a dedicated Community Builder forum yet]
I’m using a child theme with Community Builder. I’m trying to add a filter:
add_filter( 'cb_is_panel_right_enabled', function() { return false; } );
which I expect to fire on the following hook in the parent cb-layout-conditional-functions.php:
/** * Is right panel visible, should we load it? * * @return bool */ function cb_is_panel_right_enabled() { $visibility = cb_get_panel_visibility( 'right' ); $show = 'none' !== $visibility; return apply_filters( 'cb_is_panel_right_enabled', $show, $visibility ); }
and remove the panel when the conditional is evaluated in the parent footer.php:
<?php if ( cb_is_panel_right_enabled() ) : ?> <?php get_template_part( 'template-parts/panel-right' ); ?> <?php endif; ?>
… but it’s not working. Digging a bit further, I can’t see that
cb_get_panel_visibility()
is actually implemented.I can just copy the footer.php into my child theme and remove the call to that template partial, obviously – but I’d prefer to use the filters provided (and expose those vars to the customiser for users if I want).
Am I missing something really obvious here …?
Thanks in advance!
P.S. FYI, the http://buddydev.com/community-builder/child-theme-best-practices/ page linked in the child theme template doesn’t seem to exist.
Hi James,
Thank you for using Community Builder.1. The filter is correct and your code is correct too. You need to apply that code in your child theme’s functions.php
cb_get_panel_visibility () is implemented in includes/core/layout/cb-layout-conditional-functions.php2. Sorry about the broken link. I will update it.
Here is the correct link for downloading/working with Child theme
https://buddydev.com/community-builder/getting-started/using-community-builder-child-theme/Regards
BrajeshHi Brajesh,
Thanks for getting back to me.
1. The code is in functions.php (which is where I’d put any presentational filters) – but the hamburger icon is still there on the site. I’ve just noticed that the slide-in is in fact disabled, but the icon remaining will be confusing for users if it works on one side but not the other. I don’t want to start hacking the theme to pieces or using CSS to hide things – is the icon left there intentionally for some reason?
Also, I meant that I can see
cb_get_panel_visibility()
is *implemented* in cb-layout-conditional-functions.php (as you can see, I refer to the file by name in my initial post, and that’s where I found the hook) – but I don’t see a function *definition* anywhere. Perhaps I’m missing something in your code.2. Thanks – I’m aware of that link, although there is no real documentation there yet – I assume that’s being worked on (not that it’s too necessary – your code is well documented).
Thanks,
James
Hi James,
Thank you.1. The function is defined in the same file. Please check line 561.
Also, you are right about the toggle button. This needs to be updated. There is a solution though.You can set the panel visibility to ‘none’ like this
add_filter( 'cb_panel_visibility', function ( $visibility, $user_scope, $panel ) { if ( 'right' === $panel ) { $visibility = 'none'; } return $visibility; }, 10, 3 );
and it will take care of it for the toggle as well as the panel.
2. You are welcome. Yes, more document are coming in near future.
Regards
BrajeshHi James,
My bad, It is cb-layout-general-functions.php line 561.Regards
BrajeshThanks Brajesh. By the way, I’m an idiot – VS Code (which I’ve only recently started using) was referring to my .gitignore file when doing a project-wide string search, so although I had the child theme in its own repo (and therefore a separate search scope there), the /public_html rule in the .gitignore file at the root of the WP instance was stopping Code from indexing anything outside of that scope … 😂
Hi James,
No issue. We all are prone to overlooking. I am glad you found it 🙂Regards
Brajesh
You must be logged in to reply to this topic.