gmclelland Posted June 21, 2016 Share Posted June 21, 2016 Hello everyone. I’m just starting using Processwire and ran into a problem. I can’t seem to output on a template(left-sidebar.php) a repeater field that is attached to a “site-settings” page. The surrounding html prints but the $block_title and $block_body are empty. Anybody willing to take a look? Here is the code I’m using in left-sidebar.php: <?php $siteSettings = $pages->get("/site-settings/"); foreach($siteSettings->global_footer_blocks as $block) { echo "<div class=4u 12u(narrower)><section>"; echo "<header><h3>"; echo $block->title; echo "</h3></header>"; echo "<footer>" . $block->body . "</footer>"; echo "</section></div>"; } ?> On my site-settings page the repeater field is named global_footer_blocks. That repeater field contains block_title and block_body fields. Here is my output http://pastie.org/10885463 when I call print_r($siteSettings->global_footer_blocks); in left-sidebar.php. Link to comment Share on other sites More sharing options...
horst Posted June 21, 2016 Share Posted June 21, 2016 If your fields are named " block_title" and " block_body", you need to call them with its names. In your example you are calling title and body. foreach($siteSettings->global_footer_blocks as $block) { echo "<div class=4u 12u(narrower)><section>"; echo "<header><h3>"; echo $block->block_title; echo "</h3></header>"; echo "<footer>" . $block->block_body . "</footer>"; echo "</section></div>"; } Does this work? 3 Link to comment Share on other sites More sharing options...
gmclelland Posted June 21, 2016 Author Share Posted June 21, 2016 Thank you horst! That was the problem. 1 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