Jump to content

Child page's repeater field on home page


nexuspolaris
 Share

Recommended Posts

Hello,

I made a 'Services' page where I listed some certain services. I'd like to display some of them service by title, featured image and summary on home page. 

I try to get the 'service_box' repeater field's fields in home page template, but it doesn't work:

$services = $pages->find("template=services");
$service_box = $services->get("service_box");

foreach($service_box as $service) {

    $content .= "<div class='service'>";
    $content .= "   <div class='service-body'>";
    $content .= "    <h4>{$service->subtitle}</h4> ";
    $content .= "    <summary>{$service->body}</summary>";
    $content .= "  </div>";
    $content .= " </div>";
       
}

Thanks for help.

Link to comment
Share on other sites

9 minutes ago, LostKobrakai said:

find does return a pagearray, not a single page. You need findOne or get.

Thanks, it worked this way:

$services = $pages->get("template=services");
$service_box = $services->get("service_box");

But how to limit the services number on home page if I want to display only the first 3 item? This dropped error:

$service_box = $services->get("service_box, limit=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...