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

Allow registering (repeatable group) fields to be loaded into or available to a template part #19

Closed jtsternberg closed 9 years ago

jtsternberg commented 9 years ago

Example UI: homepage-custom-content 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' )

jazzsequence commented 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.

jtsternberg commented 9 years ago

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).

jazzsequence commented 9 years ago

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. :)

jtsternberg commented 9 years ago

We've begun work in this branch: https://github.com/WebDevStudios/WDS-Simple-Page-Builder/tree/template-part-data-fields

jazzsequence commented 9 years ago

Nooice!

JayWood commented 9 years ago

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.

JayWood commented 9 years ago

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' );
jtsternberg commented 9 years ago

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 */ );
bradp commented 9 years ago

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. error1

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 error2

jtsternberg commented 9 years ago

@bradp should be good w/ last push.

bradp commented 9 years ago

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.

jtsternberg commented 9 years ago

Ok, that one should be good too. Was being too aggressive w/ my jquery object caching.

jtsternberg commented 9 years ago

fyi, the dev on the template-part-data-fields branch has ceased, and everything is now in the feature/areas branch.

jazzsequence commented 9 years ago

merged feature/areas into develop.

jazzsequence commented 9 years ago

thanks @jtsternberg!!!

jtsternberg commented 9 years ago

Woo! ITS ALL HAPPENING