Dynamic sidebars on custom post types and archives

Hi

Just bought BB Theme / Page Builder today and think it is great (moving a site from Runway Framework / Visual Composer!). Am loving the ease of editing… :slight_smile:

Sorry if this is a numpty question (?!) but I am still getting my head around the BB theme / plugin hooks/filters etc.

I have a site with a Learning Management System and various different custom post types in it. My objective is to have different sidebars on different custom post single pages (for example, each course or set of lessons is to have its own individual sidebar) and some custom post types without.

I also also want to have some archives (eg blog) with a sidebar but some without a sidebar (eg courses).

In my last theme, I used a $dynamic_sidebar variable in my sidebar.php to set variables/check whether the user was logged in, registered on that course etc and then display the relevant sidebar and used page/archive settings within the theme to switch sidebars on/off for different post types.

What is the best way to achieve this using the BB Theme?

I have tried various options using the sidebar module and also using the WordPress sidebar using the Content Aware Sidebars plugin (or coding these myself in functions.php) but am struggling slightly and wondering whether there is a simpler way…

Can you recommend how you would implement this to best effect? Do you have templates for an archive and a single page with / without sidebars or point me in the right direction.

Any help would be much appreciated.

Many thanks in advance / kind rgds

Mark

Hey Mark! Thanks for the kind words about Beaver Builder! Glad to have you on board.

You’ll probably want to use native WordPress sidebars as opposed to building them with Beaver Builder. You can build them with Beaver Builder, but you can’t build archive pages with BB so you wouldn’t be able to use them there.

There are probably a few ways to load a custom sidebar. I would check out the tpl-sidebar.php file in the Beaver Builder theme. This is the template that’s used for pages when a sidebar is needed. We have a class called FLTHeme that handles a lot of the logic for our theme display. One of the methods is the sidebar method. You could always override our sidebar method with your own and load sidebars depending on the criteria you mentioned (which course, logged in our out, etc).

You’ll need to register your sidebars in your theme, too. Here’s an article that discusses that:
https://codex.wordpress.org/Function_Reference/register_sidebar

You could also try adding the logic to the sidebar.php file. If you open the file, on line 10 you could scrap that line and write your own logic to load sidebars.

I hope that helps. It’s a bit tricky to come up with the best solution for YOUR site without knowing more about the configuration you’re using. Best bet would be to dig through our code to get an understand of how it works, then tweak/modify it to suit your needs.

Out of curiosity, which LMS are you using?

Thanks Mark.

Hi Robby

No worries - I will have no hesitation in recommending it to my clients. :slight_smile:

I will have a look at the classes / pages you mentioned - scanning through your code, I missed the significance of Line 10 in sidebar.php!

I am using LearnDash (http://www.learndash.com) for my LMS. I have previously used Sensei (Woo) on other projects but recently reviewed quite a few LMS’s. LearnDash is very good and offers great functionality (goodies such as Certificates, integration with Gravity Forms, BadgeOS/Credly, Zapier and lots more).

Thanks for you help! :slight_smile:

Mark

Awesome! Let us know if you run into any more trouble!

I was curious about the LMS because we just spent last week in Cabo with the LifterLMS guys! I don’t have a lot of experience using an LMS, but judging from the team, I would recommend checking out LifterLMS too.

Wow! Expensive that LifterLMS.

I love Learndash, it’s the best, most rock solid, standards based system out there. It’s as good for a University as it can be for a solo entrepreneur.

I haven’t implemented it yet in BeaverBuilder, but soon :slight_smile:

Interesting. I’ll check that one out. Thanks Nomad!