elabx Posted March 2, 2017 Share Posted March 2, 2017 I want to render a repeater matrix repeater type with the following code: foreach($page->content_repeater_matrix as $content){ if($content->type == "hero"){ $content->render(); break; } } The field has its own field template asigned in fields/content_repeater_matrix/hero.php. Why shouldn't this work? It would seem to me to be "the processwire way" I got this one working in fields/content_repeater_matrix.php: <?php foreach($value as $item) { echo $item->render(); } Am I trying to call render in the wrong context? Link to comment Share on other sites More sharing options...
kixe Posted March 2, 2017 Share Posted March 2, 2017 maybe just a missing echo? foreach($page->content_repeater_matrix as $content){ if($content->type == "hero"){ echo $content->render(); break; } } 2 Link to comment Share on other sites More sharing options...
Robin S Posted March 2, 2017 Share Posted March 2, 2017 4 hours ago, elabx said: Why shouldn't this work? It would seem to me to be "the processwire way" Not only "the processwire way", but also the way that is demonstrated in the documentation: foreach($page->test_matrix as $item) { if($item->type == 'blockquote') { echo " <blockquote> <p>$item->quote</p> <cite>$item->quote_cite</cite> </blockquote> "; } else if($item->type == 'bodycopy') { echo " <h2>$item->title</h2> $item->body "; } else if($item->type == 'gallery') { // and so on... } } Link to comment Share on other sites More sharing options...
elabx Posted March 2, 2017 Author Share Posted March 2, 2017 2 hours ago, kixe said: maybe just a missing echo? foreach($page->content_repeater_matrix as $content){ if($content->type == "hero"){ echo $content->render(); break; } } Guess I just jumped to fast on the forum, thanks! 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