Skip to:
Content
Pages
Categories
Search
Top
Bottom

Customizing BuddyPress Template Files


  • Oxibug
    Participant

    @oxibug

    Hi There!

    According to you docs Theme Compatibility & Template Files I should copy one of available templates and copy its folder [/bp-nouveau/buddypress] to my [/THEME/buddypress] and It’s working V. GOOD

    BUT, When the user activate the other template [legacy] the error [Fatal error: Call to undefined function(s) bp_nouveau_#####] appears for all pages because it reads the function from the new theme’s buddypress folder.

    So, Is there a fix for that issue? I try to move [/THEME/buddypress] folder to [/THEME/bp-nouveau/buddypress] but it’s NOT correct.

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)

  • Venutius
    Moderator

    @venutius

    You’d need to change the overload file to be one from the legacy template.


    Oxibug
    Participant

    @oxibug

    So it’s not possible, I should notify my clients to work only with [nouveau] template .. Right?


    Venutius
    Moderator

    @venutius

    That would probably be best, otherwise you’d have to write your own progrmatic way of switching between the two template files depending on the theme used.


    Oxibug
    Participant

    @oxibug

    That’s my question bro, I cannot find the way to do that because the folders in the two templates are same.

    if there’s a function to define the folder to read files from according to the user option

    Ex. get_option(‘_bp_theme_package_id’) -> [/THEME/temp1/buddypress] or [/THEME/temp2/buddypress]…

    Thanks Pal


    Venutius
    Moderator

    @venutius

    You’d have to do something like this:

    function venutius_start() {
         
        if( function_exists( 'bp_register_template_stack' ) ) {
            bp_register_template_stack( 'venutius_register_template_location' );
    	}
        // if viewing a member page, overload the template
        if ( bp_is_user()  ) {
            if ( bp_get_theme_package_id() == 'legacy' ) {
    			add_filter( 'bp_get_template_part', 'venutius_replace_template_legacy', 10, 3 );
    		}
            if ( bp_get_theme_package_id() == 'nouveau' ) {
    			add_filter( 'bp_get_template_part', 'venutius_replace_template_nouveau', 10, 3 );
    		}
    	}
    }
    add_action( 'bp_init', 'venutius_start' );
    
    function venutius_register_template_location() {
        return <directory>; //replace with the main directory you are putting your new template files in
    }
    
    function venutius_replace_template_nouveau( $templates, $slug, $name ) {
        switch($slug) {
    
    	case 'members/single/profile/change-avatar' :
    		if ( '<your_directory>/members/single/profile/change-avatar.php' ) ) {
    			return array( 'members/single/profile/change-avatar.php' );
    			break;
    		} else {
    			return $templates;
    			break;
    		}
    
    	}
    	return $templates;
    }
    
    function venutius_replace_template_legacy( $templates, $slug, $name ) {
        switch($slug) {
    	case 'members/single/profile/change-avatar' :
    		if ( file_exists( '<your directory>/'members/single/profile/change-avatar.php' ) ) {
    			return array( 'members/single/profile/change-avatar.php' );
    			break;
    		} else {
    			return $templates;
                            break;
    		}
    
    	}
    	return $templates;
    }
    

    Something like that should work, not tested it though but you should get the idea.

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