Jump to content

Output a repeater field from a different page


gmclelland
 Share

Recommended Posts

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

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?

  • Like 3
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...