Skip to:
Content

BuddyPress.org

Opened 9 years ago

Closed 9 years ago

#6588 closed enhancement (fixed)

Members Type - needs a template stack hierarchy entry

Reported by: hnla's profile hnla Owned by: r-a-y's profile r-a-y
Milestone: 2.4 Priority: normal
Severity: normal Version:
Component: Templates Keywords: has-patch
Cc:

Description

We need to add a template path and file name to the stack for members Directory

Currently as:

$new_templates = apply_filters( 'bp_template_hierarchy_members_directory',   array(
 'members/index-directory.php'
) );

update to take into account the new Member Type directories if registered.

$new_templates = apply_filters( 'bp_template_hierarchy_members_directory',   array(
'members/index-type-' . sanitize_file_name( bp_get_current_member_type() ) . '.php',
 'members/index-directory.php'
) );

Patch addresses this but I could only find bp_get_current_member_type() to fetch the dir type being viewed but this doesn't feel right as it's more an actual members tag although does work as expected to show different templates matching to different member type dir urls.

Attachments (3)

6588-01.patch (550 bytes) - added by hnla 9 years ago.
Add 'Type' to template stack
6588-02.patch (560 bytes) - added by hnla 9 years ago.
Add string 'directory' to file name
6588.03.patch (1.1 KB) - added by r-a-y 9 years ago.

Download all attachments as: .zip

Change History (12)

@hnla
9 years ago

Add 'Type' to template stack

#1 @imath
9 years ago

+1 and maybe you could add a new template for the single_template_hierarchy()

eg: 'members/single/index-member-type-' . sanitize_file_name( bp_get_member_type( bp_displayed_user_id() ) . '.php',

But maybe we should check member types have been registered first with bp_get_member_types()

Last edited 9 years ago by imath (previous) (diff)

#2 @DJPaul
9 years ago

My gut says the filename should be index-directory-$type.php because I believe all the other template stacks share the start of that in common, but great idea.

#3 @hnla
9 years ago

@imath good point hadn't thought about single member or checking do we need to for this process?

@DJPaul Another good point, yes will look at the file name as index-directory-type-*.php

#4 @imath
9 years ago

i think we need to check if ( '' !== bp_get_current_member_type() ) before adding it to the stack else we could have
index-directory-.php

and for the single template we should have something like :

$new_templates = array(
	/* existing templates */
);

// Make sure some member types are registered
if ( bp_get_member_types() ) {
	// None is the member has no member type
	$type = 'none';

	if ( bp_get_member_type( bp_displayed_user_id() ) ) {
		$type = sanitize_file_name( bp_get_member_type( bp_displayed_user_id() );
	}

	$new_templates[] = 'members/single/index-type-' . $type . '.php';
}

$new_templates = apply_filters( 'bp_template_hierarchy_members_single_item', array_merge( 
	$new_templates, 
	array( 'members/single/index.php' ) 
) );
Last edited 9 years ago by imath (previous) (diff)

@hnla
9 years ago

Add string 'directory' to file name

#5 @hnla
9 years ago

@imath Thanks struggling at the moment to get single templates working at all so pulled it from my o2 patch.

I'll look at your suggestion, however we don't check if components are turned off and run... just realised why I'm thinking that out wrong, your right check for types is required.

And just seen where I was going wrong!

What I could do with an opinion on is what point in that member/single stack it should be placed I have it last but one.

Last edited 9 years ago by hnla (previous) (diff)

@r-a-y
9 years ago

#7 @r-a-y
9 years ago

imath is right in comment:4.

03,patch is what I would suggest. The one change I made to imath's suggestion is I do not think we need a special template if no member type is set. When this happens, just just use the regular 'members/index-directory.php' template to do your modifications. Misread imath's comment :)

As for the members single template, a member can have multiple types associated with their account, so I wouldn't really consider adding a specialized template for this.

Version 2, edited 9 years ago by r-a-y (previous) (next) (diff)

#8 @hnla
9 years ago

I defer to your patch r-a-y

#9 @r-a-y
9 years ago

  • Owner set to r-a-y
  • Resolution set to fixed
  • Status changed from new to closed

In 10218:

Members: Add member type to template hierarchy for members directory.

Props hnla, DJPaul, imath.

Fixes #6588.

Note: See TracTickets for help on using tickets.