Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/04/2015 01:47:36 PM (9 years ago)
Author:
imath
Message:

Improve template loading for Groups single items home pages.

  • Make sure an activity sub navigation will be generated if the displayed group has a custom front page.
  • Make sure no members sub navigation is generated if the activity component is not active and the Group has no custom front. As, in this case the home page of the group is already displaying the members template.
  • Make sure some Groups single item conditional tags are behaving the right way:
    • bp_is_group_home() is true when on the home page of the group (eg: site.url/groups/single-group/).
    • bp_is_group_activity() is true when the activity page of the group is displayed. It can be the home page of the group or its activity page (eg: site.url/groups/single-group/activity).
    • bp_is_group_members() is true when the members page of the group is displayed. It can be the home page of the group or its members page (eg: site.url/groups/single-group/members).
  • Introduce a new conditional tag: bp_is_group_custom_front() to check if the home page of the group is using a custom front template.
  • Introduce a new template tag bp_groups_front_template_part() used to choose the appropriate template to load for the home page of the group (activity, members, or the custom front).
  • Introduce a template hierarchy for the buddypress/groups/single/front.php template so that it is possible to have different front pages according to the ID, slug or status of the Group.
  • And finally make sure the introduced improvements are back compatible with themes who forgot to update their buddypress/groups/single/home.php and buddypress/activity/post-form.php templates.

Props r-a-y, boonebgorges, DJPaul, and imath :)

Fixes #6388

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-template.php

    r10152 r10184  
    25532553 */
    25542554function bp_is_group_activity() {
    2555     return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) );
     2555    $retval = false;
     2556
     2557    if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'activity' ) ) {
     2558        $retval = true;
     2559    }
     2560
     2561    if ( bp_is_group_home() && bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
     2562        $retval = true;
     2563    }
     2564
     2565    return $retval;
    25562566}
    25572567
     
    25862596 */
    25872597function bp_is_group_members() {
    2588     return (bool) ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) );
     2598    $retval = false;
     2599
     2600    if ( bp_is_single_item() && bp_is_groups_component() && bp_is_current_action( 'members' ) ) {
     2601        $retval = true;
     2602    }
     2603
     2604    if ( bp_is_group_home() && ! bp_is_active( 'activity' ) && ! bp_is_group_custom_front() ) {
     2605        $retval = true;
     2606    }
     2607
     2608    return $retval;
    25892609}
    25902610
     
    26312651function bp_is_group_single() {
    26322652    return (bool) ( bp_is_groups_component() && bp_is_single_item() );
     2653}
     2654
     2655/**
     2656 * Is the current group page a custom front?
     2657 *
     2658 * @since 2.4.0
     2659 *
     2660 * @return bool True if the current group page is a custom front.
     2661 */
     2662function bp_is_group_custom_front() {
     2663    $bp = buddypress();
     2664    return (bool) bp_is_group_home() && ! empty( $bp->groups->current_group->front_template );
    26332665}
    26342666
Note: See TracChangeset for help on using the changeset viewer.