Opened 9 years ago
Closed 9 years ago
#6588 closed enhancement (fixed)
Members Type - needs a template stack hierarchy entry
Reported by: | hnla | Owned by: | 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)
Change History (12)
#1
@
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()
#2
@
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
@
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
@
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' ) ) );
#5
@
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.
#7
@
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 Misread imath's comment :)'members/index-directory.php'
template to do your modifications.
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.
Add 'Type' to template stack