This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Apply page banners to all bbpress pages

  • Creator
    Topic
  • #21385
    Wendell Harness
    Participant

    I have figured out how to setup bbpress, customize the main bbpress page with a banner, but it doesn’t stick to bbpress subpages (like when viewing a thread, profile, etc.). This is actually expected behavior from bbpress, but I was hoping you could shine some light on how to make a banner stick to all bbpress-related pages.

    Examples:

    http://wpmule.com/beta/support/ (this page shows the banner without issue because it is using a custom WPJS2b3 layout)

    http://wpmule.com/beta/forums/forum/web-hosting/ (this page, for example, loses the banner as expected, but I’d like to show the banner on all forum-related pages)

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #21399
    Jason Bobich
    Keymaster

    Hi,

    There’s no user feature where this would be possible. You’d have to achieve this through customization. The global config that happens when a page loads is how the theme knows to display a banner. So, you can use bbPress’s function is_bbpress() to know if it’s a bbPress page, and then just filter onto the theme’s frontened config.

    function my_forum_banner( $config ) {
    
        if ( function_exists('is_bbpress') && is_bbpress() ) {
            $config['banner'] = get_post_meta( 123, '_tb_banner', true ); // 123 is the ID of the page w/banner
        }
        
        return $config;
    }
    add_filter('themeblvd_frontend_config', 'my_forum_banner');
    #21401
    Wendell Harness
    Participant

    Thanks Jason! That works wonderfully except for one small detail: the transparent header over content. 🙂

    http://wpmule.com/beta/forums/forum/pre-sales-support/

    #21402
    Jason Bobich
    Keymaster

    See the method set_config() in /framework/includes/class-tb-frontend-init.php

    There’s also a “suck_up” value you can filter to true on the same $config array you’re already filtering.

    $config['suck_up'] = true;
    #21479
    Wendell Harness
    Participant

    Thank you Jason.

    Rethinking all of this through, I think what I really am wanting to do is set a banner with transparent header as default for everything, with the page/post/whatever title centered in the banner. Almost like maybe I want to make a template, then apply it as a global template for everything. Am I making sense? If so, is there a way? I’m not finding anything in the forum or documentation, but maybe I’m not using the right search terms.

    #21487
    Jason Bobich
    Keymaster

    Yeah, sure why not. But this is going to take some basic understanding of WordPress filters and arrays in PHP.

    Every time any page loads on your site, there is this big global configuration array that gets setup that holds various settings for the output of the current page. You filter this big array with the filter “themeblvd_frontend_config”.

    As an experiment to understand what’s getting setup, print out all of it at the top of the screen like this:

    function my_frontend_config( $config ) {
        echo ''; print_r($config); echo '</pre>';
        return $config;
    }
    add_filter('themeblvd_frontend_config', 'my_frontend_config');

    Note: that line should read echo ‘<pre>’; print_r($config); echo ‘</pre>’; — My forum doesn’t allow this to print in a code block.

    … So, this array that prints out is what you can edit with your function hooked to the filter. Within your function you’re simply manipulating $config, and you’ve got all WordPress and bbPress conditionals at your disposal.

    https://codex.wordpress.org/Conditional_Tags

    https://codex.bbpress.org/bbpress-conditional-tags/

    The two parameters of this array you’re filtering for the banner are $config['suck_up] which is simply a boolean of true or false, and then $config['banner] which is an array of options for a banner.

    When $config['banner] is empty, no banner displays on the current page. So, you’d add your array of options for a banner, and then the banner displays on the given page.

    The array of banner options you’re building is getting passed into themeblvd_get_banner(). So, to understand how you’re setting up this array, you need to look at the function in the theme and see. /framework/includes/media.php

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.