Open dustyf opened 9 years ago
Love @dustyf's suggestion :+1:
just documenting here the proposed part header:
/**
* Part Name: My Template Part Name
* Description: A cool description about my part
* Areas: before_content, after_content, content, hero
*/
Part Name would be used as the display name in the dropdown, if it exists Description could be used if that part was selected/saved as the description for that CMB2 field Areas would be the specific Page Builder Areas that the part can be included and would restrict the part to only display in those dropdowns
Should be fixed in branch feature/refactor-2. This will be merged to develop after more testing.
I'm still seeing template parts that are assigned to a specific area show up in the dropdowns for other areas.
Did you use "Areas" like shown above or "Area"? I used Area for the header.
Yeah, I've been using Areas. That's probably it.
This came up on our call this morning. We thought it would be valuable to only allow a builder part to be used within a certain area. Some parts may not make sense in another area or could break another area unless front-end devs put in a lot of extra work to ensure design compatibility. It would be best to not give an option to place parts in areas if we know they will break the area or should not go in that area for whatever reason.
One option I have for declaring this, is to require a file header for builder template parts like how WordPress themes require them for page templates. You can use the following function to easily parse this: https://developer.wordpress.org/reference/functions/get_file_data/
In there you could declare a builder area which that part can only work for. This may also be a better way to display the names of template parts rather than the current method of taking the file name. It would allow better descriptions that don't fit in the few words you probably want to use for a file name.