Closed jtsternberg closed 9 years ago
I might need to pick your brain about exactly what you're thinking. I think I have some ideas but want to work through what the end result would look/act like.
Sounds good. It looks like we might need this for a project, so will be a good time to see if it makes sense to contribute back here. When we get to that point, we can have a chat (unless you wanted to start earlier for some reason).
It's unlikely that I'll get to it anytime soon since we don't need that currently for what we're working on. Would love to see what you come up with tho, if you want to have a go with it. :)
We've begun work in this branch: https://github.com/WebDevStudios/WDS-Simple-Page-Builder/tree/template-part-data-fields
Nooice!
I believe this is good to go, thanks in no small part to @jtsternberg Spent hours trying to formulate a plan and he just ninja's the thing.
So I went in and documented the methods and updated the readme files, versioning, etc... We can chat about the additions at any time, just ping me or justin.
An example filter using the new additions:
<?php
/**
* Trending post fields
*/
function wds_uwish_trending_posts_fields( $fields ) {
$fields[] = array(
'name' => __( 'Select how far back you would like analytics to pull from', 'uwishunu' ),
'id' => 'timeval', // Use this key when accessing your data with the template tag
'type' => 'ga_timeval', // This is a custom field type, but can be any CMB2 built-in field type
);
return $fields;
}
// Notice the 'trending-posts', this is the template part slug.
add_filter( 'wds_page_builder_fields_trending-posts', 'wds_uwish_trending_posts_fields' );
This is not QUITE ready to merge. @briannaorg is working on some UI/UX improvements so that it is more clear that the fields are associated to the template part.
IN the actual template part, this is the helper function to pull that part-specific data out:
$timeval = wds_page_builder_get_this_part_data( 'timeval' );
If you wanted to pull another template-part's data, you would use:
$timeval_for_trendingposts = wds_page_builder_get_part_data( 'trending-posts', 'timeval', /* $post_id optional */ );
Two quick bugs for yall.
Bug 1: If adding or moving a template part to where a part that has fields is, the fields do not move, but stay in the location of the existing part.
Bug 2: If the first template part added to a page has fields, all of the next parts will also have the same fields showing
@bradp should be good w/ last push.
The bug where the fields don't move is fixed.
The bug when starting from a new page is not fixed. Starting from a blank page, if the first part has fields, the rest get them too.
Ok, that one should be good too. Was being too aggressive w/ my jquery object caching.
fyi, the dev on the template-part-data-fields branch has ceased, and everything is now in the feature/areas branch.
merged feature/areas into develop.
thanks @jtsternberg!!!
Woo! ITS ALL HAPPENING
Example UI: But below 'Content Package Tag' would be the template part dropdown selector.
The data could be made available to the template part via a template tag like
get_page_builder_layout_field( 'package_tag' )