[buddypress-trac] [BuddyPress] #997: New theme structure doesn't work with parent theme not being a BP framework

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Thu Sep 17 03:40:18 UTC 2009


#997: New theme structure doesn't work with parent theme not being a BP framework
------------------------+---------------------------------------------------
  Reporter:  Detective  |       Owner:          
      Type:  defect     |      Status:  reopened
  Priority:  minor      |   Milestone:  1.1     
Resolution:             |    Keywords:          
------------------------+---------------------------------------------------
Changes (by Detective):

  * status:  closed => reopened
  * resolution:  worksforme =>


Comment:

 Well, the default templates work ok, this ticket is about a problem using
 a custom bp framework.

 I found the problem. I'll provide a patch this weekend (here in Chile
 we're on holydays :) Independence Day(s) ). However, if someone want to
 pull this earlier, better :)

 This is the problem:

 {{{
 function groups_screen_group_home() {
    // ...
    if ( file_exists( TEMPLATEPATH . '/groups/single/home.php' ) )
       bp_core_load_template( apply_filters( 'groups_template_group_home',
 'groups/single/home' ) );
    else
       bp_core_load_template( apply_filters( 'groups_template_group_home',
 'groups/group-home' ) );
 }
 }}}

 bp_core_load_template calls locate_template to load the right file. This
 works ok almost always, except when the template files have new names,
 because the existance of the new template filename is being checked only
 on the parent theme by using TEMPLATEPATH. Since in this setup the parent
 theme doesn't contain that file, the old filename is passed to
 bp_core_load_template.

 A simple solution is to replace all these instances with something like
 this:

 {{{
 $located = locate_template( array( 'groups/single/home.php' ), false );
 if ( $located != '' )
    bp_core_load_template( apply_filters( 'groups_template_group_home',
 'groups/single/home' ) );
 else
    bp_core_load_template( apply_filters( 'groups_template_group_home',
 'groups/group-home' ) );
 }}}

 This duplicates some work (the filesystem is searched twice for the
 correct template) but it's easier to code and more future proof (since in
 a few versions the old themes will be discarded, the only modification
 needed is to delete "the else branch".

-- 
Ticket URL: <http://trac.buddypress.org/ticket/997#comment:5>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list