Opened 8 years ago
Closed 7 years ago
#7434 closed enhancement (fixed)
BP Email Template Hierarchy
Reported by: | espellcaste | Owned by: | DJPaul |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Emails | Keywords: | has-patch 2nd-opinion |
Cc: |
Description
Currently, the order of the BP Email template hierarchy is as follow:
- Look for the template on the theme folder: (single-bp-email-slug-title.php)
- Look for the template on the theme folder without slug on it (single-bp-email.php)
- Look for the template on buddypress/assets/emails/single-bp-email.php
That's fine until you need to customize the templates so that they are almost completely different from one another. I have a scenario where I have "components" on the site. Each component has its own email, with different styling.
So for me, it is easier to create a custom single-bp-email-slug-here.php and customize to the way I want. But creating specific template for each email is adding up to the theme folder, together with others single-custom-posttypes.php and page-custom-template.php, etc.
So I'd like to suggest that the priority of the folder to fetch the templates from, should be BuddyPress and not the theme's.
Here follows the order I believe would be better:
- Look for the template on buddypress/assets/emails/single-bp-emails-slug-title.php
- Look for the template on the theme folder: single-bp-emails.php
- Look for the template on buddypress/assets/emails/single-bp-emails.php)
Maybe single-bp-emails-ID.php would also be an option. I created a patch with the example above.
Attachments (2)
Change History (10)
This ticket was mentioned in Slack in #buddypress by slaffik. View the logs.
8 years ago
#3
@
8 years ago
- Milestone changed from 2.8 to 2.9
Starting from here: https://wordpress.slack.com/archives/buddypress/p1486413456003644
#4
@
8 years ago
@espellcaste - Based on what you wrote here:
Here follows the order I believe would be better: Look for the template on buddypress/assets/emails/single-bp-emails-slug-title.php Look for the template on the theme folder: single-bp-emails.php Look for the template on buddypress/assets/emails/single-bp-emails.php)
I added another patch based on your suggestions. The problem with single-email-order.patch
is you would break existing template checks for /single-bp-email-POST_SLUG.php
.
You could also use the provided 'bp_email_get_template'
filter to add in your extra template to the beginning of the array.
This ticket was mentioned in Slack in #buddypress by espellcaste. View the logs.
8 years ago
#6
@
8 years ago
Hi! Sorry, but I noticed now I uploaded the wrong patch... :( I'll take extra care next time. Anyway!
@r-a-y Yes! You are right. But my objective was to change this behavior from BuddyPress masquerading it with my personal needs.
Putting the bp-emails templates in the theme main folder didn't seem the right place for them.
In the scenario I described, putting the templates in the BP email folder seems organized, or "right". :)
I think you left "assets" off the path of the first line changed in your patch, based on what you wrote above.
If you want to look up what WordPress' post template hierarchy looks like as far as slugs and IDs go, we can ensure consistency with that.