Jump to content


Photo

MarkupPageFields repeater missing


  • Please log in to reply
2 replies to this topic

#1 interrobang

interrobang

    Distinguished Member

  • Members
  • PipPipPipPip
  • 105 posts
  • 44

  • LocationMunich, Germany

Posted 12 June 2012 - 02:04 PM

I am trying to output all content of all my pages on a single page to get a quick overview where some content is still missing. It doesn't have to be pretty, and the resulting output of the MarkupPageFields.module is sufficient for my purpuse, but I am missing the content of my repeater field.

Is there anything simple I can do to include my repeaters fields?

This is basically my code:

function listPageFields($page) {
	echo "<h1>{$page->title}:</h1>";
	echo $page->renderFields();

	if($page->numChildren) {
		foreach($page->children as $child) listPageFields($child);
	}
}

listPageFields($pages->get('/'));


#2 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,521 posts
  • 845

  • LocationVihti, Finland

Posted 12 June 2012 - 02:48 PM

Not sure if this works, but let's assume your repeater field is called "repeater":

function listPageFields($page) {
	    echo "<h1>{$page->title}:</h1>";
	    echo $page->renderFields();
	    foreach($page->repeater as $p) {
			    echo $p->renderFields();
	    }
	    if($page->numChildren) {
			    foreach($page->children as $child) listPageFields($child);
	    }
}
listPageFields($pages->get('/'));


#3 interrobang

interrobang

    Distinguished Member

  • Members
  • PipPipPipPip
  • 105 posts
  • 44

  • LocationMunich, Germany

Posted 13 June 2012 - 06:53 AM

Thank you apeisa,
It worked. I just changed your code to this, so that empty/waiting repeaters are not echoed:

foreach ($page->repeater as $p) {
	 if ($p->status == Page::statusOn) echo $p->renderFields();
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users