pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 265 forks source link

Loop Field Type #109

Closed viruthagiri closed 2 years ago

viruthagiri commented 12 years ago

Description modified September 1st, 2015 and July 4th, 2022 by @sc0ttkclark

Feature Summary

A loop field will be a field that contains other fields. For example a Pod called 'book' could have a loop field called 'chapters', which had its own set of fields such as, 'chapter_title', 'chapter_content', 'chapter_start_page' and 'chapter_end_page'. An item in the book Pod, could have as many entires in the chapters field as necessary, and each one would have its own set of fields, with their own values.

A lot of planning has gone into this feature, but its implementation has been delayed. Performance improvements that we plan to address in 2.3.19 and 3.0 have been prioritized over loop fields as they are essential for proper implementation of loop fields.

Work to be done (needs to be revisited)

We are actively seeking contributors for any of the open tasks above, please hop in and help out if you're interested! If you are unsure of how to get started or have any questions, feel free to ask @sc0ttkclark here or at http://pods.io/chat/) for help getting started.

Original issue summary

Hello pods team, I'm using magic fields 2.0 which contains features like "add another field" and "add another group" type of fields. Yesterday one of my internet friend recommended pods 2.0. I tested it and i really love it. Magic fields 2.0 stores the data as metadata. I'll get performance issue. Thats why i would like to use pods 2.0. Pods satisfies me everything except that "add another field" and "add another group" type of field.

Here is the snapshot of what i'm asking Before duplicating the field: http://wiki.magicfields.org/lib/exe/fetch.php?media=v2_field_duplicate_post.jpg

After duplicating the field: http://wiki.magicfields.org/lib/exe/fetch.php?media=v2_field_duplicate_complete.jpg

Before duplicating the group: http://wiki.magicfields.org/lib/exe/fetch.php?media=v2_group_duplicate_post.jpg

After duplicating the group: http://wiki.magicfields.org/lib/exe/fetch.php?media=v2_group_duplicate_remove.jpg

Does pods 2.x has that feature and as a pods newbie am i missing something?

sc0ttkclark commented 12 years ago

Yes this is planned for Pods 2.0, I wasn't sure if I could pull it off in time, so it may be pushed into 2.1

viruthagiri commented 12 years ago

Thanks. I would be very happy if you include that feature in Pods 2.0 :)

sc0ttkclark commented 12 years ago

Mike, this one is on you (further down already discussed priority list), let's look at Attachments (can provide you the code) for how we'll handle repeatable fields themselves. Admining of repeatable fields is going to get sticky, so we'll tackle that as a separate thing in the admin area.

Pezzab commented 12 years ago

Apologies for reviving this thread. Having started tinkering with Pods 2.0 beta in anger this is so far the only feature that I'm missing. Other than here I see it has been mentioned on the podsframework.org blog. I hope it is still on the roadmap somewhere.

Otherwise Pods 2.0 is unbelievably good. The flexibility and power has always been astounding - the additional ease the new UI in 2.0 adds to the mix knocks it out of the park :)

sc0ttkclark commented 12 years ago

Yeah, this is queued up for Pods 2.1, we've got @dontfeedthecode on it and he's already designing some pretty great looking screens.

Pezzab commented 12 years ago

Sweet, that'll another plugin I can wave bye bye to once it's implemented :)

dandv commented 12 years ago

Awesome feature, I'm interested in it too.

sc0ttkclark commented 12 years ago

Looking good so far!

Screenshot

sc0ttkclark commented 11 years ago

Unfortunately we have to push this one into 2.2, more details coming soon on the plans for this one. Not opposed to this landing for 2.1 but it doesn't look like there's enough time to implement now.

roosterjm2k2 commented 11 years ago

I put off a project as long as I could waiting on this, so I guess its either the ugly magic fields interface, or paying for ACF ... (still, awesome work, and i'll be using pods later)

sc0ttkclark commented 11 years ago

Sorry Josh, we wish we could push it up, we'll try to get it done and in beta ASAP, just had a few things come up that made it too tough to ship it in time for 2.1

Pezzab commented 11 years ago

No worries - worth waiting for :)

franz-josef-kaiser commented 11 years ago

+1

eccentricpixel commented 11 years ago

Did this functionality make it into the latest commit?

sc0ttkclark commented 11 years ago

No, we adjusted the release schedule and instead of releasing 2.1.1 for bug fixes, we're releasing that as 2.2 as it includes additional features and enhancements. This is now slated for 2.3, still technically our next major release. It's nearly done in design, so we should start seeing pieces of it make it's way into the code in January.

kelfy commented 11 years ago

can't wait to see this loop field.

kelfy commented 11 years ago

Couldn't find this function on the latest alpha release. Would that be more delay for this?

sc0ttkclark commented 11 years ago

It's in progress, but hidden for developer testing. It's at about 20% right now, held up in design/ui work. Pods 2.3 in currently in Alpha, so there's still a lot going into it. Our goal is to release Pods 2.3 on or before WP 3.6 (see http://make.wordpress.org/core/version-3-6-project-schedule/)

So this isn't going to get delayed, it's slated for Pods 2.3 and that's my full intention. Worst case, I may have to stop work on all other features to get this one out.

dikaso commented 11 years ago

+1 for this.

This is what's holding me to swap to pods. I'll start with slow migration to pods... but till this come out i won't be satisfied.

Anyway great work people ;)

sc0ttkclark commented 11 years ago

Unfortunately, the time has come, I've gotta punt this one to Pods 2.4, everything's held up right now on design and we're working on getting that lined up. Until then, the #1095 should be useful for many uses that the loop field would have normally been used for.

Pezzab commented 11 years ago

I'm working on something right now using ACF repeatable fields as a placeholder for this functionality. No biggie - I can press on using that. I'd rather you got it right than ship something that won't work as it should.

kelfy commented 11 years ago

Same here. Have to use ACF instead

sc0ttkclark commented 11 years ago

Sorry, wish there was something more I could do to get this out in time, out of my hands unfortunately. I've set in motion a solution to get this out in time for Pods 2.4 though, it'll just cost me us a bit more.

sc0ttkclark commented 11 years ago

Also, alternatively, Pods and ACF work together, so you can use ACF for the loop fields, and Pods for everything else. Again, sorry for the inconvenience.

Pezzab commented 11 years ago

No worries,. I'm using an ACF/Pods combo already :)

Halvard commented 11 years ago

Can't wait for this!

dechowdev commented 11 years ago

So now 3.6 have been released... Are there any news? :)

sc0ttkclark commented 11 years ago

Pods 2.4 has an official date of the end of September now, I've brought in an additional resource to work on the html/css/js side of this, which I'll be unable to complete as I have other areas of 2.4 that need my focus (lower memory footprint for low memory environments, etc). We may be beta-able by mid-September if all goes to plan.

dechowdev commented 11 years ago

So this means repeatable group/fields are set of end September? :) — Im Mobile, if I reply later than expected I apologize

On Thu, Aug 8, 2013 at 3:34 PM, Scott Kingsley Clark notifications@github.com wrote:

Pods 2.4 has an official date of the end of September now, I've brought in an additional resource to work on the html/css/js side of this, which I'll be unable to complete as I have other areas of 2.4 that need my focus (lower memory footprint for low memory environments, etc). We may be beta-able by mid-September if all goes to plan.

Reply to this email directly or view it on GitHub: https://github.com/pods-framework/pods/issues/109#issuecomment-22323526

sc0ttkclark commented 11 years ago

Right, this is the main feature we're focusing on for Pods 2.4.

lapidus commented 11 years ago

+1

sc0ttkclark commented 11 years ago

Back on track with this feature, @curtismchale is again on the case!

Big question for those who have a vested interest in using this feature though -- what code would you want to use for your loop field data? Is it as simple as a multi-dimensional array or do you think it needs to be something more?

// This may or may not be what we want
// Let's think about it and figure out what's best
$chapters = $pod->field( 'chapters' );

foreach ( $chapters as $chapter ) {
    echo '<h2>' . $chapter[ 'name' ] . '</h2>';

    $page_num = 1;

    foreach ( $chapter[ 'page' ] as $page ) {
        if ( 1 < $page_num ) {
            echo '<hr />';
        }

        echo '<h3>Page ' . $page_num . '</h3>';

        echo '<div class="page-content">';
        echo apply_filters( 'the_content', $page[ 'content' ] );
        echo '</div>';

        $page_num++;
    }
}
jchristopher commented 11 years ago

I love a good ol' multidimensional array. What you have is exactly what I'd envision.

sc0ttkclark commented 11 years ago

@jchristopher the only issue is that these would all be 'field' outputs, not 'display', so while you loop through the content, you'd have to have your own processing (see above), vs what you'd normally use with $pod->display( 'content' )

So I'm not 100% sure what we'd want here, maybe we need a new object-based output type for loop fields too:

// This may or may not be what we want
// Let's think about it and figure out what's best
$chapters = $pod->field( 'chapters', 'fields' );

foreach ( $chapters as $chapter ) {
    echo '<h2>' . $chapter->display( 'name' ) . '</h2>';

    $page_num = 1;

    $pages = $chapter->field( 'pages', 'fields' );

    foreach ( $pages as $page ) {
        if ( 1 < $page_num ) {
            echo '<hr />';
        }

        echo '<h3>Page ' . $page_num . '</h3>';

        echo '<div class="page-content">';
        echo $page->display( 'content' );
        echo '</div>';

        $page_num++;
    }
}

So for the new field object, it would basically be a mini-Pods object that you'd only use display/field from. Still a lot more to be considered on the backend to make this possible for relationship fields traversal handling.

mastef commented 11 years ago

how would relationship fields be addressed in the loop?

$chapter->display( 'book.author' ) ?

sc0ttkclark commented 11 years ago

@mastef That's the tricky part, we need new traversal handling for tableless fields within loop fields, relationships can't be stored in wp_podsrel the same way.

mastef commented 11 years ago

loop fields could be a separate pod simply displayed inline inside a pod?

sc0ttkclark commented 11 years ago

@mastef that's #291

mastef commented 11 years ago

Oh yes! That would actually solve the whole issue. If a repeatable field would simply automate this process, wouldn't it?

sc0ttkclark commented 11 years ago

It will allow for automating this process if we can get the initial code done first.

sc0ttkclark commented 11 years ago

We need to figure out how we're going to handle loop field tableless fields and their relationship traversal. I don't see an easy way of using wp_podsrel for this, because these are fields within a field, and it can be multiple levels deep, we don't have the columns to handle that and it wouldn't be efficient.

So traversal in find() is out of the question, but for ->display( 'chapters.pages.characters.name' ) we'd need to pull the related ID(s) from the field's array itself. I think that sounds right, just need some validation here :)

sc0ttkclark commented 11 years ago

Sounds like #1661 is going to be a prerequisite to handling relationship traversal and field/display methods for the loop field 'fields' output type.

sc0ttkclark commented 11 years ago

Latest progress on loop fields can be seen in this video: https://www.youtube.com/watch?v=6Zf26fAEBRw

kelfy commented 11 years ago

That is awesome. A long awaited function finally there. Look forward to see the next release.

kenwiesner commented 11 years ago

Fantastic! So excited to start using it!

Halvard commented 11 years ago

I've been waiting for this for years. Brilliant stuff!

Halvard L. Simonsen Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Saturday, September 7, 2013 at 12:18 AM, Ken Wiesner wrote:

Fantastic! So excited to start using it!

— Reply to this email directly or view it on GitHub (https://github.com/pods-framework/pods/issues/109#issuecomment-23973036).

mhhansen commented 11 years ago

awesome, can't wait! I'm also waiting for this stuff, thanks for all efforts guys!

mastef commented 10 years ago

still eagerly awaiting it! :)

Katamo commented 10 years ago

Hi sirs. Any uptate on this?

mastef commented 10 years ago

I think it's time to get this finished, it's really a big blocker.

Otherwise please suggest a viable work-around to have loop-fields in wp-admin only ( e.g. as part of a linked other pods ). We just need SOME way to make loop fields work for our daily projects. ( Pretty please )