a-ok Posted February 6, 2015 Share Posted February 6, 2015 Hi folks, I used to be a big fan of WP, but luckily found ProcessWire and in general it has been so great and super flexible... so thanks for that and all your hard work. It's appreciated. One thing I was a big fan of on WP when using the ACF (Advanced Custom Fields) was the 'Flexible Content' add-on (http://www.advancedcustomfields.com/add-ons/flexible-content-field/) which essentially allowed you to build a series of elements to use (textarea, image etc) then when a user came to build this section on the CMS, they could build a flexible page using those defined elements. So one page might be textarea, image, image, textarea and another may be image, textarea, image, image, image, textarea etc. They have the fields and they build the order. Is there anything PW offers in this respect? I was checking out Tables (https://processwire.com/api/modules/profields/table/) but it's quite strict and not that flexible (unless I am missing something!) Thanks and hope you can help, R Link to comment Share on other sites More sharing options...
Soma Posted February 6, 2015 Share Posted February 6, 2015 You're looking for Field "PageTable" not "Table". Edit: Or "Repeater". 1 Link to comment Share on other sites More sharing options...
Macrura Posted February 6, 2015 Share Posted February 6, 2015 maybe this could work? http://modules.processwire.com/modules/fieldtype-page-table-extended/ 1 Link to comment Share on other sites More sharing options...
renobird Posted February 6, 2015 Share Posted February 6, 2015 ProcessWire has ACF's older brother. See above. 1 Link to comment Share on other sites More sharing options...
a-ok Posted February 6, 2015 Author Share Posted February 6, 2015 Thanks all. Is there any docs on PageTable? I'm struggling to find out what it actually is. My guess is that you create templates with the field you want, so you might have a template for a textfield, and a template for an image. Then you add these templates to the PageTable field and then you can organise and add as many as you want? If so, sounds good. Would be nice to do it with just fields rather than pages of fields. Thanks so much Link to comment Share on other sites More sharing options...
Soma Posted February 6, 2015 Share Posted February 6, 2015 You mean a Cook Book? ;P Don't think official yet, but If you search for ProcessWire PageTable you'll get tons of. https://processwire.com/talk/topic/6417-processwire-profields-table/?p=63119 1 Link to comment Share on other sites More sharing options...
Soma Posted February 6, 2015 Share Posted February 6, 2015 BTW if you search for "processwire flexible content" in google you'll get lots of lengthy discussion already there. 1 Link to comment Share on other sites More sharing options...
a-ok Posted February 6, 2015 Author Share Posted February 6, 2015 Thanks for your input. I'm still struggling to see how this is similar to the ACF side of things. Why can't it use fields rather than pages. I don't need pages created for a slider to be used on a journal page etc. Do you know what I mean? Link to comment Share on other sites More sharing options...
Macrura Posted February 6, 2015 Share Posted February 6, 2015 Thanks for your input. I'm still struggling to see how this is similar to the ACF side of things. Why can't it use fields rather than pages. I don't need pages created for a slider to be used on a journal page etc. Do you know what I mean? but a slide could be a template, where each slide is one page, or the slider could be a template where the slides themselves are repeaters or page table, or images with regular or extended fields. the only way to get the page to be configurable how you want is to use the page table extended Link to comment Share on other sites More sharing options...
a-ok Posted February 7, 2015 Author Share Posted February 7, 2015 Thanks for all your help here, guys. I'm working through it but the only thing I can't find is how to actually output the layout in a template? Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 7, 2015 Share Posted February 7, 2015 Do you mean output in general or outputting infos from repeaters and/or pagetables? Link to comment Share on other sites More sharing options...
a-ok Posted February 8, 2015 Author Share Posted February 8, 2015 I mean outputting the data saved to a template from a PageTable. The foreach/if loops etc. I can't find out how to do it... Link to comment Share on other sites More sharing options...
Martijn Geerts Posted February 8, 2015 Share Posted February 8, 2015 @Richard, something like this: foreach ($page->table as $row_page) { echo $row_page->render(); } 2 Link to comment Share on other sites More sharing options...
a-ok Posted February 9, 2015 Author Share Posted February 9, 2015 But how do I state what I want each 'section' to look like? So my PageTable setup as an image field, images field, text and a wide image field. Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 9, 2015 Share Posted February 9, 2015 A pagetables behave exactly like a page field with multiple pages. It just looks different. So $row_page is just a page object like $page or $pages->get($someSelector). Link to comment Share on other sites More sharing options...
a-ok Posted February 9, 2015 Author Share Posted February 9, 2015 Thanks all. I worked it out. Below is an example <?php foreach ($page->flexible_layout as $layout) : ?> <?php if ($layout->text) : ?> <div class="row"> <?php echo $layout->text; ?> </div> <?php elseif ($layout->image) : ?> <div class="row"> <?php echo $layout->image; ?> </div> <?php elseif ($layout->wide_image) : ?> <div class="row"> <?php echo $layout->wide_image; ?> </div> <?php elseif ($layout->slider) : ?> <div class="row"> <?php echo $layout->slider; ?> </div> <?php endif; ?> <?php endforeach; ?> Link to comment Share on other sites More sharing options...
Soma Posted February 9, 2015 Share Posted February 9, 2015 Each entry in PageTable is a page and can have it's own template file, just like a normal page. So you can create a template file for each and use the $page->render() to output the markup. Like Martijn's code showed. It's very convenient and flexible reusable. foreach ($page->table as $row_page) { echo $row_page->render(); } the template file for "text" may just contain <div class='row'> <?php echo $page->body ?> </div> And so on. 3 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