How to fetch fields?

I will be able to help you with the side panel and some css or js, but about the Ajax, I’m sur Pedro will help you better than me, I won’t be able to help and give you good starting point unfortunatly. He built it exactly for the project needs and I use it as it is without having study it :frowning:

1 Like

Ok so after an hour of searching and reading, still I’m struggling to understand the structure.
Like where exactly will I put the below code? I have edited it according to the data I need.

<?php if(!kirby()->request()->ajax()) { snippet('header'); } ?>

  <?php if($image = $page->image()): ?>
  <img src="<?= $image->url() ?>" alt="<?= $image->alt()->html() ?>">
  <?php endif ?>

  <h1><?= $page->title() ?></h1>
  <p><?= $page->description() ?></p>
  <p><?= $page->price() ?></p>
  <p><?= $page->calories() ?></p>

<?php if(!kirby()->request()->ajax()) { snippet('footer'); } ?>

I am really unsure if I’m supposed to create a new template or snippet to put the above code.

Basically, I have a menu template and I’m listing the grandchildren using the below code.

Template: menu.php

<div>
  <?php snippet('dishes', ['dishes' => $dishes]) ?>
</div>

Snippet: dishes.php

<ul>
  <?php foreach ($dishes as $dish): ?>

  <li>
    <div>

      <?php if($image = $dish->image()): ?>
      <img src="<?= $image->url() ?>" alt="<?= $image->alt()->html() ?>">
      <?php endif ?>

      <div>
        <h2 ><?= $dish->title() ?></h2>
        <p><?= $dish->price(); ?>.00</p>
      </div>

    </div>
  </li>

  <?php endforeach ?>
</ul>

It seems this code is the “grandchildren/product” content so it should be in its own template. Or maybe I did not anderstood correctly.

It is the grandchildren.

Anyway, I have opened a new topic regarding this Ajax. This original post is already solved for me and it’s going too deep as well.

Thank you everyone!

How do I make this post SOLVED?

Replace the yellow tags just above the topic title with Kirby 3 solved Let’s go on on the new topic :wink:

1 Like