Jump to content

frontend output of pagetable


herr rilke
 Share

Recommended Posts

hi everyone,

i'm pretty new to processwire and trying to figure out if pw is a replacement for contao in same use cases.
so many interesting concepts - but still not to easy to set up a page with sections and all that ?

anyway:
i am able to output all children of a given page by their template:

// only templates starting "section_"
$tpls = $templates->find("name^=section_");

foreach ($page->children("template=$tpls") as $child){
	$content .= $child->render();
}

these children were insertet by a pagetabel field and they are rendered as expected.

if i try to do that using the pagetable object, it does not work:

	if ($page->pagetable) {

		foreach ($page->pagetable as $pt) {
			$content .= $pt->name .'<br>'; // works
			$content .= $pt->id .'<br>';   // works too
			$content .= $pages->find('id=' . $pt->id)->render(); // returns a formatted link ... ?!
		}
	}

surprisingly that only give's me a link to the child page instead of display it's contents.

anyone to guide me... ?

 

Link to comment
Share on other sites

17 hours ago, herr rilke said:
foreach ($page->pagetable as $pt) {

In this code, $pt is already a Page object so you don't need to get it again from $pages. You can just call the render method on it directly.

foreach($page->pagetable as $pt) {
	$content .= $pt->render();
}

 

17 hours ago, herr rilke said:

but still not to easy to set up a page with sections and all that

For this sort of thing you'll find that Repeater Matrix is money well spent.
https://processwire.com/store/pro-fields/repeater-matrix/

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...