Nested One-pager Issue

It was probably stupid for me to attempt this, but I’m trying to wire up the concept illustrated here:

But instead of using that as the primary page, I’m trying to set it up so I can create as many child pages as I want using the same approach. Basically a blog, with each entry page being broken up into parts like the One Pager example.

I implemented the following in my top level template:

      <?php foreach ($page->children() as $part) : ?>
          <?php snippet($part->intendedTemplate(), compact('part')) ?>
      <?php endforeach ?>

But I can’t seem to access any of the fields in the actual Part templates.

This is the blueprint I’m using as my parent “One Pager” post:

    headline: Parts
    type: pages
    empty: Add at least a project intro you noob.
    status: all
    info: "{{ project.intendedTemplate }}"
    image: false
      - project-intro
      - project-summary
      - project-screenshot
      - project-text-row
      - project-image-and-text
      - project-left-image-and-text
      - project-quote

And this is the blueprint for the project-intro Part:

title: Project Intro
icon: title

    type: files
    label: Hero Image
    query: site.images
    empty: No file selected yet.
    multiple: false
      parent: site
    type: text
    label: Project One-liner

In snippets/project-intro.php I have the following:

    <project-head style="background: blue;">

      <section class="intro">
        <h3><?php echo $page->title(); ?></h3>
        <h1><?php echo $page->heroSummary(); ?></h1>

heroSummary(); returns nothing. I’m assuming it’s because I can’t reference it by $page->, but I don’t know how to go “deeper” into the part templates to get that value.

Sorry for the novel. :grimacing:

Since you are passing the part variable to the snippet, you have to also use it inside the snippet, so

 <h3><?php echo $part->title(); ?></h3>


Good night and good luck, time for me to get some sleep.

1 Like