herr rilke Posted August 25, 2023 Share Posted August 25, 2023 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 More sharing options...
ottogal Posted August 26, 2023 Share Posted August 26, 2023 I'd try findOne() instead of find(). Link to comment Share on other sites More sharing options...
Robin S Posted August 26, 2023 Share Posted August 26, 2023 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 More sharing options...
herr rilke Posted August 26, 2023 Author Share Posted August 26, 2023 thanks anyone and thank yout, robin s, that was the solution! plus i guess i spent some money on pro fields ? 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