Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#7372 closed enhancement (no action required)

Add page for Member Type directory listing

Reported by: Venutius Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.3.0
Component: Members Keywords: dev-feedback
Cc:

Description

I've been playing with member types and it occurs to be that the directory pages that are created for each member type should create/use their own page in the same way that other BuddyPress components use pages.

That way each component page can be dealt with in similar ways from the perspective of page styling.

Change History (2)

#1 @slaFFik
5 years ago

  • Keywords dev-feedback added
  • Milestone changed from Awaiting Review to Under Consideration
  • Version set to 2.3.0

I'm not sure we will go this route - give for each member type an own WordPress page.
As your main concern seems to be around styling and templating, we can append a new <body> class like member-type-students in addition to the current directory type members.

Also, you can easily change the whole page template for a directory using a code like this (code not tested):

<?php
function venutius_7372_change_page_template() {
    if ( bp_is_members_directory() && bp_get_current_member_type() === 'students' ) ) {
        add_filter( 'template_include', function ( $template ) {
            $new_template = locate_template( array( 'page-templates/member-type-students.php' ) );
                if ( ! empty( $new_template ) ) {
                    return $new_template;
                }

                return $template;
        }, 99 );
    }
}

add_action( 'wp', 'venutius_7372_change_page_template' );

You can also redefine only particular BuddyPress part of the member type directory using this:
https://codex.buddypress.org/themes/theme-compatibility-1-7/template-hierarchy/#member-directory-page

/buddypress/members/index-directory-type-{member_type}.php when viewing member type specific directory page, {member_type} is the current member type.
Last edited 5 years ago by slaFFik (previous) (diff)

#2 @DJPaul
5 years ago

  • Milestone Under Consideration deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi @Venutius - thanks very much for your suggestion. I hope the code @slaFFik helped you achieve this on your site.

Generally speaking, the Page-to-BuddyPress-component mapping dates back to version 1.6, which I think -- with hindsight -- all involved then, now regret making that particular architectural decision. Sooner or later we will migrate to using something like rewrite rules, and these pages and their mappings will disappear. I don't believe it's worth adding more features around the page mapping logic at this time.

Last edited 5 years ago by DJPaul (previous) (diff)
Note: See TracTickets for help on using tickets.