3 times a blog. How to make 3 pages with 3 sections dynamic?

Sorry, yes now I do.

Bildschirmfoto%2018

Bildschirmfoto%2019

Bildschirmfoto%2020

There is something wrong with your numbering.

  • The uber page has two pages with the same sorting number
  • the freenow page mixes two types of sorting 0_ for alphabetical sorting and 28_ for standard numbered sorting, that is not possible.

Could you please also post the content of your info.php and news.php and gotcha.php snippets?

yes

Info.php

Bildschirmfoto%2023

news.php
(but with a link in it that I tried)

Bildschirmfoto%2022

gotcha.php

(this must be different because it’be fotos/ figure elements, but I didn’t try yet)

Bildschirmfoto%2024

Ok, thanks. That doesn’t explain your result yet. What is in your gegenseite.php template?

I have a feeling that we have to restructure your content structure again, because in your first post you didn’t say that you wanted each section to have multiple entries.

and

Ah, ok, you repeat the same loop for each section, that doesn’t make sense.

Although this is what I was trying to express ;(

Maybe, but that wasn’t clear from the structure you posted in your first post.

In this case, infos and news (and maybe the gotchas as well should be container pages and have subpages that contain the individual items.

Like this:

Me again.

The goddess of lost Kirby newbies kick started me. The trick did a snippet that collects each entry of each fruit sections.

Snippet

    <?php foreach ($section->children()->paginate(3) as $info): ?>
            <section class="teaser">
                <h2><?= $info->title() ?></h2>
                <?= $info->text()->kt() ?>
                <a class="more-link" href="<?= $info->url() ?>">Mehr…&raquo;</a>

            </section>
        <?php endforeach ?>

I made 3 snippets for each sort of fruit.

With this method, I get 3 entries for each fruit section on a collection page.

This is the collection page

    <?php foreach ($page->children() as $child) {
      snippet($child->intendedTemplate(), ['section' => $child]);
    } ?>

:joy:

But:

Now I need to collect all entries - not only 3 - of each categorie (which are info, news, gotchas) for each fruit on a page.

All infos of bananas listed on a page.

All news of bananas listed on a page.

All gotchas of bananas listed on a page.

Same with oranges and Guaves.

So, I started with infos of bananas and made a content folder and a corresponding blueprint and a corresponding template for all infos of bananas on a collection page.

The Problem:

I should be able to simply reuse the loop of the collection page but no, that fetches all infos, news and gotchas. I only need one of those categories.

Ähh… .

I tried several things but and even was able to make a loop that fetches things, but most of the time I get an error: unknown variable “info”.

After consulting the docs and researching “$section” I do this loop:

<?php foreach($pages->listed() as $section) {
  snippet($section->uid(), ['data' => $section]);
}
?>

But this gives me nothing.

I somehow was able to make a loop that gives me a list of all infos, but just with the name of the pages of infos, but without the content of the entries. Unfortunatly I can’t remember how I did that, so no code for that.

I guess, I need to find the right variables? Or is it the combination of blueprints and templates and folders?

In this case, instead of hardcoding the limit, I would pass it as a variable to the snippet, depending on where it is used

<?php foreach ($page->children() as $child) {
      snippet($child->intendedTemplate(), ['section' => $child, 'limit' => 3]);
    } ?>

Then in the snippet:

   <?php 
// let's check if a limit variable was passed, if yes, limit children, if not, use all children
$infos = isset($limit) ? $section->children()->limit($limit) : $section->children();
foreach ($children as $info): ?>
            <section class="teaser">
                <h2><?= $info->title() ?></h2>
                <?= $info->text()->kt() ?>
                <a class="more-link" href="<?= $info->url() ?>">Mehr…&raquo;</a>

            </section>
<?php endforeach ?>

I get an error:

Undefined variable: children

<section class="abschnitte">
<h1>News zu <?= $page->title() ?></h1>
<div class="grid-container">
   <?php 
// let's check if a limit variable was passed, if yes, limit children, if not, use all children
$infos = isset($limit) ? $section->children()->limit($limit) : $section->children();
foreach ($children as $info): ?>
            <section class="teaser">
                <h2><?= $info->title() ?></h2>
                <?= $info->text()->kt() ?>
                <a class="more-link" href="<?= $info->url() ?>">Mehr…&raquo;</a>
 
            </section>
<?php endforeach ?>
</div>
</section>
 

Is it “child” not children?