ryan Posted February 14, 2012 Share Posted February 14, 2012 I've been working on making repeatable fields for ProcessWire for a couple weeks and actually now have it nearly ready. I need to do some more testing before releasing it, but wanted to give you a little preview. (please view the full screen version for better quality) Accessing repeatable fields from the API is super-easy. They are fully searchable/selectable with the API just as easily as with any other fields. So if you wanted to find all pages that had a buildings field with a floors value of 50 or more, you'd do this, for example: $pages->find("buildings.floors>=50"); Lets say you are on the page with a 'buildings' field and you want to print out all the building names and number of floors. It works exactly the same as page references: foreach($page->buildings as $p) { echo "<p>{$p->building_name}</p> has {$p->floors} floors.</p>"; } 10 Link to comment Share on other sites More sharing options...
Soma Posted February 14, 2012 Share Posted February 14, 2012 Awesome! Yeah first! Now going to look at video.... Edit: Looks really great! Thank you for this preview! For sure very useful. Now my question. Would it be any way possible to have to be able define multiple "block" templates (with different fields each) for the repeater field? Then when adding a new item, it would ask for the block template to select first. Pretty much the same as it is now, just with variable templates. I can imagine it would require something complete different concept/codewise. It's just what I kinda "expected" from (the) repeatable page element, so I don't have to use child pages anymore. It can be very handy to be able to define "blocks" that can be chosen from, to build a page. TItle, Video, Text-Image, Linklist, Text. Do you see a good way to add such "variable blocks" feature to PW through a module, much similar like this one? Maybe they're also just invisible childpages that are editable and sortable via the parent page's block field. Just blah blah, I don't really know what all need to be considered. Have you implemented this repeater using hidden pages? 3 Link to comment Share on other sites More sharing options...
apeisa Posted February 14, 2012 Share Posted February 14, 2012 That is amazing stuff, looks so good! Now back to coding everyone... Link to comment Share on other sites More sharing options...
ryan Posted February 14, 2012 Author Share Posted February 14, 2012 Thanks for checking it out, glad you guys like it so far! Soma what you described is quite similar to how this system works. It literally is creating a system template behind-the-scenes, and each repeatable element is a page. You can have as many repeatable fields, and repetitions of those repeatable fields, as you want. You can even stack them (repeaters in repeaters) though I don't think I'd want to. The pages are hidden outside of the site structure, so you won't see where they are at first. Likewise, the templates are hidden as system templates, so you won't see them in your usual development. But if you want to put in a template file to provide the rendering capability for the items, you can... enabling you to do something like $building->render(); I'm working on a 'detach' capability that lets you move the repeater template and parent into your site structure, should you want to. But this 'detach' capability won't appear in the first version. The reality is, repeaters are more approachable if you don't have to see the technical details of how they work, right in your site structure. But the fact that they can be part of your site structure opens a lot of possibilities, so that's why I've already started work on making them detachable ... it'll make building large sites a lot easier if you can create 100 pages on 1 screen, for example. Link to comment Share on other sites More sharing options...
Marty Walker Posted February 15, 2012 Share Posted February 15, 2012 Ryan, This is more that I had hoped for when this feature was mentioned a while ago. Outstanding work. Will this makes it's way into PW 2.2 or future versions? Regards Martin Link to comment Share on other sites More sharing options...
diogo Posted February 15, 2012 Share Posted February 15, 2012 Great work Ryan! This will make it so much more intuitive for editors in some situations! And I also think it will bring more people to PW, as it was obviously one of the most requested features. Link to comment Share on other sites More sharing options...
AnotherAndrew Posted February 15, 2012 Share Posted February 15, 2012 Ryan, that's awesome and extremely useful. Thanks. Just an idea and I don't know how feasible it is, but wouldn't it make since to have repeating fields already built into the core processwire fields? For example, when adding a text field, image field, etc, a user would have an option for "make repeatable". Link to comment Share on other sites More sharing options...
diogo Posted February 15, 2012 Share Posted February 15, 2012 Andrew, I also thought of that. But since you would have to program your template to deal with them anyway, I don't think it would be any easier to use a system of that kind instead of this one. Link to comment Share on other sites More sharing options...
fnode Posted February 15, 2012 Share Posted February 15, 2012 Thank you, Ryan! Link to comment Share on other sites More sharing options...
fenton Posted February 15, 2012 Share Posted February 15, 2012 truly awesome! thanks Ryan Link to comment Share on other sites More sharing options...
Oliver Posted February 15, 2012 Share Posted February 15, 2012 Ryan, I love it! Soma, I absolutely get what’s your point. Especially for editors it would be a very comfortable solution to deal with repeatable elements of different templates. Maybe their should be a kind of helper field type, that just allows you to manage a page’s child pages as repeatable elements, so editors don't have to deal with creating child pages manually. Its input field setup in the page edit process would look just like ryan’s here, showing blocks with the child pages’ fields. The editor could choose from the allowed templates for new child pages. And in templates the field would directly provide the page array like in repeatable elements. Of course it just would be a kind of shortcut for stuff that could be done manually already. Right now I’m working on a project, where such a thing would be pretty useful. 2 Link to comment Share on other sites More sharing options...
almonk Posted February 15, 2012 Share Posted February 15, 2012 This looks awesome Ryan amazing work! Its input field setup in the page edit process would look just like ryan’s here, showing blocks with the child pages’ fields. The editor could choose from the allowed templates for new child pages. And in templates the field would directly provide the page array like in repeatable elements. Totally agree with this Link to comment Share on other sites More sharing options...
tsdtsdtsd Posted February 15, 2012 Share Posted February 15, 2012 Awesome! That's what i was waiting for Can't wait for you to publish it Link to comment Share on other sites More sharing options...
raydale Posted February 15, 2012 Share Posted February 15, 2012 This looks amazing Ryan! Thanks for creating a video showing the functionality too - it makes things very clear. I'm personally glad to see that you haven't just gone the Drupal route of adding a simple checkbox on a single field creation for 'make repeatable'. This is an easy way to do things but your approach allows for repeatable fieldsets or groups of fields which is much more powerful. Like others here - I can't wait to see this in a release of PW. Link to comment Share on other sites More sharing options...
Michael Murphy Posted February 15, 2012 Share Posted February 15, 2012 I missed this little Valentines day surprise yesterday Very excited - this is going to be very useful - Thanks Ryan! Link to comment Share on other sites More sharing options...
formmailer Posted February 15, 2012 Share Posted February 15, 2012 Great stuff, Ryan! The funny thing is that I didn't think I would need repeatable fields... but after seeing the video I came up with several different uses of them in my current project. Obviously I didn't know what I was missing and/or what to expect of repeatable fields. /Jasper Link to comment Share on other sites More sharing options...
ryan Posted February 15, 2012 Author Share Posted February 15, 2012 Thanks for all the great feedback! This module is ready now, but I feel like I need to give it a more thorough testing on this end so will probably aim to have it to you this weekend or early next week. I'm short on time today, but am hoping to catch up with all of the questions here tomorrow. Link to comment Share on other sites More sharing options...
diogo Posted February 15, 2012 Share Posted February 15, 2012 This is great Ryan! I'm dying to test it Link to comment Share on other sites More sharing options...
pers0n Posted February 15, 2012 Share Posted February 15, 2012 Cool, I could use these for slideshows for sure. Each repeatable item doesn't link to its own content does it? I know we could add a link to another page, but I guess I didnt understand it 100% and probably wont until I play with it. Link to comment Share on other sites More sharing options...
nikola Posted February 16, 2012 Share Posted February 16, 2012 Ryan, this is great news! Now we can extend PW further more. Thanks! Link to comment Share on other sites More sharing options...
slkwrm Posted February 16, 2012 Share Posted February 16, 2012 Ryan, this is just mind-blowing! Congratulations! This feature takes PW to a totally new level! Will it be possible to have pagination for repeatable fields in the back-end? Link to comment Share on other sites More sharing options...
ryan Posted February 17, 2012 Author Share Posted February 17, 2012 I wanted to add that the idea behind the repeatable fields implementation came from Diogo and his post (below), as well as related posts from Apeisa, Adamkiss and Martinluff (and I may be missing others) sparked the direction used in the new repeatable fieldtype. While a little different than what he mentioned, Diogo's original post, and follow-up posts are what got the ideas and momentum towards this direction going for the current implementation: http://processwire.c...ndpost__p__4519 Initially I'm just trying to get a reasonably simple implementation of repeatable fields going, but down the road we'll expand to broaden the possibilities consistent with peoples' needs... perhaps with pagination and more. Though admittedly, terms like pagination within a field make me wonder if we're going too far. But I've started to revisit some code in the FieldtypeRepeater module based on some feedback here, working towards giving you more page management possibilities with it. But don't expect too much here, this will just be a beta test version 1 and it's not going to perform any miracles. And like with anything new, I'm sure there will be bugs to uncover as well. Repeatable fields like this do seem to open a lot of new possibilities. I think part of that is just that we've not had them quite like this before (at least in PW), and it seems like a whole new dimension to explore. But while you could apply repeatable fields like this to all kinds of uses, I don't necessarily think we should be doing that. They will be great for some things, but they will also be tempting to use in places where they really shouldn't (I've already had to restrain myself). These repeatable fields with all kinds of possibilities will blur the line on that and demand more discipline. I think that like every page is viewed at it's own URL, it should also be edited at it's own URL (in most situations). But for repetitive data that may use a page + template by convenience rather than by need--repeaters will be perfect. I just don't want to see people turn their sites into spreadsheets. I personally will be using them on only half of sites that I build (I estimate). But I can't wait to get this out for you all to try and see where it might help to simplify tasks and open new possibilities. I think I've only scratched the surface with my own testing here, so this fieldtype will continue to evolve as your needs do. Thanks for all the great ideas and interest in this. Link to comment Share on other sites More sharing options...
diogo Posted February 18, 2012 Share Posted February 18, 2012 Thanks for the reference Ryan! I hope soon I will be able to contribute with modules, instead of ideas only... Link to comment Share on other sites More sharing options...
slkwrm Posted February 18, 2012 Share Posted February 18, 2012 Ryan, could you eleborate a little bit more, what are the do's and don'ts for repeatable fields? Link to comment Share on other sites More sharing options...
wes Posted February 18, 2012 Share Posted February 18, 2012 This. Changes. Everything. Awesome work, Ryan! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now