WebDevStudios / WDS-Simple-Page-Builder

Uses existing template parts in the currently-active theme to build a customized page with rearrangeable elements.
GNU General Public License v2.0
136 stars 25 forks source link

Add ability to limit parts to only be used in a certain area #30

Open dustyf opened 9 years ago

dustyf commented 9 years ago

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.

gregrickaby commented 9 years ago

Love @dustyf's suggestion :+1:

jazzsequence commented 9 years ago

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

dustyf commented 9 years ago

Should be fixed in branch feature/refactor-2. This will be merged to develop after more testing.

jazzsequence commented 9 years ago

I'm still seeing template parts that are assigned to a specific area show up in the dropdowns for other areas.

dustyf commented 9 years ago

Did you use "Areas" like shown above or "Area"? I used Area for the header.

jazzsequence commented 9 years ago

Yeah, I've been using Areas. That's probably it.