How to make Woothemes Canvas and bbPress work together

The theme Canvas from WooThemes does not compatible with bbPress. But if we like Canvas and want a forum on our site, what should we do? Simple. Just make Woothemes Canvas and bbPress work together. Here is step by step manual how to do it.

1. You have created a canvas child theme. If not, You MUST do it. Otherwise all changes will be overwrited next theme update.

2. Create subdirectory css in child theme folder and place there bbpress.css, You can get it here. It’s bbpress.css from plugin with all necessary changes. Please remember files and folders ownership and permissions. Should be something like fig.1

Canvas and bbPress. Fig. 1. bbPress.css installation

Fig. 1. bbPress.css installation

3. Following code explains bbPress that our theme is compatible with it and adds visual editor TinyMCE to input field on bbPress pages.

if (!is_admin()) if(!session_id()) session_start();
/* BBPRESS */
function bbp_enable_visual_editor( $args = array() ) {
    $args['tinymce'] = true;
    return $args;
}
add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor');

So, if You need this, add the code to functions.php child theme (fig. 2.).

Canvas and bbPress. Fig. 2. Add code to functions.php

Fig. 2. Add code to functions.php

4. Copy page.php and content-page.php from main theme folder to child theme. This templates will be used to to display forum information.

5. Edit content-page.php to disable everything below forum. Functions woo_post_inside_after() and woo_post_after() should be called only if page is not a forum page.

if(! is_bbpress() ) {
        ?>
    </section><!-- /.entry -->
    <div></div>
<?php
    woo_post_inside_after();
}

And the second part:

if(! is_bbpress() ) {
    woo_post_after();
    $comm = get_option( 'woo_comments' );
    if ( ( $comm == 'page' || $comm == 'both' ) && is_page() ) { comments_template(); }
}
Canvas and bbPress. Fig. 3. content-page.php

Fig. 3. content-page.php

6. Find the line in content-page.php 

if ( ! is_singular()  )  {

and change it to

if ( ! is_singular()  && ( ! is_bbPress()) ) {

This will display all forum pages using call the_content(). The piece of code should looks like:

if ( ! is_singular() && (! is_bbPress()) ) {
    the_excerpt();
} else {
    the_content(__('Continue Reading →', 'woothemes') )
}

7. Insert following code in page.php in the beginning just below template definition

if (! function_exists('is_bbPress')) {
    function is_bbPress() {
        return false;
    }
}
Canvas and bbPress. Fig. 4. The beginning page.php

Fig. 4. The beginning page.php

This code defines function is_bbPress() if it’s not exists. It’l help if one deactivates bbPress plugin, site will continue working without any changes.

8. Breadcrumbs. We have to change breadcrumbs line generator from Canvas theme in all forum pages to one from bbPress plugin. Do do this, in file page.php one have to change line
woo_loop_before();
with following code:
if(! is_bbpress() ) {
    woo_loop_before();
} else { ?>
    <div><?php bbp_breadcrumb(array('sep' => '&gt;')); ?></div><br /> <br /> <?php
}

and add

div.bbp-breadcrumb {
    display: none; /*this will hide all breadcrumbs*/
}

.truebreadcrumbs div.bbp-breadcrumb {
    display: block; /*this will display breadcrumbs you've created*/
}

to /* =Breadcrumb and Tags chapter in bbpress.css. If You downloaded it from my site, this code already there.

That’s all. Have a fun!

Describes how to make Woothemes Canvas and bbPress work together as step by step manual.

, , ,

No comments yet.

Leave a Reply