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-templates/bp-legacy/buddypress-functions.php

    r10180 r10184  
    929929
    930930    $activity_id = 0;
    931     if ( empty( $_POST['object'] ) && bp_is_active( 'activity' ) ) {
     931    $item_id     = 0;
     932    $object      = '';
     933
     934
     935    // Try to get the item id from posted variables.
     936    if ( ! empty( $_POST['item_id'] ) ) {
     937        $item_id = (int) $_POST['item_id'];
     938    }
     939
     940    // Try to get the object from posted variables.
     941    if ( ! empty( $_POST['object'] ) ) {
     942        $object  = sanitize_key( $_POST['object'] );
     943
     944    // If the object is not set and we're in a group, set the item id and the object
     945    } elseif ( bp_is_group() ) {
     946        $item_id = bp_get_current_group_id();
     947        $object = 'groups';
     948    }
     949
     950    if ( ! $object && bp_is_active( 'activity' ) ) {
    932951        $activity_id = bp_activity_post_update( array( 'content' => $_POST['content'] ) );
    933952
    934     } elseif ( $_POST['object'] == 'groups' ) {
    935         if ( ! empty( $_POST['item_id'] ) && bp_is_active( 'groups' ) )
    936             $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $_POST['item_id'] ) );
     953    } elseif ( 'groups' === $object ) {
     954        if ( $item_id && bp_is_active( 'groups' ) )
     955            $activity_id = groups_post_update( array( 'content' => $_POST['content'], 'group_id' => $item_id ) );
    937956
    938957    } else {
    939958
    940959        /** This filter is documented in bp-activity/bp-activity-actions.php */
    941         $activity_id = apply_filters( 'bp_activity_custom_update', false, $_POST['object'], $_POST['item_id'], $_POST['content'] );
     960        $activity_id = apply_filters( 'bp_activity_custom_update', false, $object, $item_id, $_POST['content'] );
    942961    }
    943962
Note: See TracChangeset for help on using the changeset viewer.