Problem with structure Method

Hello,

i want to create some FAQ with the structure method, but i don’t know how this works. Iam newbie to PHP.
My Template looks Like this:

    <?php

// define
$faq_list = $page->faq()->toStructure();

?>

<?php snippet('header') ?>

  <main class="main" role="main">

    <div class="container blank-page">

	<div class="thecontent">
	<h1><?php echo $page->title()->kirbytext() ?></h1>
      <?php echo $page->text()->kirbytext() ?>
	


<div class="row row-fix kontaktbereich">
	<div class="col-lg-6 col-md-6">
	
	
<?php foreach($faq_list as $faq_entry):

  <?php $frage = $page('faq')->children()find($faq_entry->frage());
?>
<h1><?php echo $frage->text() ?></h1>
<?php endforeach ?>
	
	</div>
	<div class="col-lg-6 col-md-6 adresse"><?php echo $page->hinweis()->kirbytext() ?></div>
	</div>
</div>
		</div>
		

	<?php snippet('footer') ?>
  </main>

And my Blueprint like this:

<?php if(!defined('KIRBY')) exit ?>

title: Page
pages: true
files: true
fields:
title:
label: Title
type: text
text:
label: Text
type: markdown
hinweis:
label: Hinweis
type: markdown

faq:
label: FAQ
type: structure
entry: >
{{frage}}

{{antwort}}
fields:
frage:
label: Frage
type: text
antwort:
label: Antwort
type: text

Try this:

<?php
// define
$faq_list = $page->faq()->toStructure();
?>

<?php snippet('header') ?>
  <main class="main" role="main">
    <div class="container blank-page">
	  <div class="thecontent">
	    <h1><?php echo $page->title()->kirbytext() ?></h1>
        <?php echo $page->text()->kirbytext() ?>
	
        <div class="row row-fix kontaktbereich">
	     <div class="col-lg-6 col-md-6">
         <?php foreach($faq_list as $faq_entry): ?>
			<h1><?php echo $faq_entry->frage() ?></h1>
			<div class"antwort"><?php echo $faq_entry->antwort() ?></div>
         <?php endforeach ?>
	
	     </div>
	     <div class="col-lg-6 col-md-6 adresse"><?php echo $page->hinweis()->kirbytext() ?></div>
	    </div>
     </div>
   </div>
	<?php snippet('footer') ?>
  </main>

or along those lines. I have added an answer div. I don’t know why you were trying to find a page in children if the text for the questions and answers is in the structure entries?

Perfect! Thank You very much. Thats exactly what jam trying to do :slight_smile:

how can i give the div in the the loop a unique class id? I try with this, but its not like i expect:

<?php
    // define
    $faq_list = $page->faq()->toStructure();
    $i = 0;
?>
    
    <?php snippet('header') ?>
      <main class="main" role="main">
        <div class="container blank-page">
    	  <div class="thecontent">
    	    <h1><?php echo $page->title()->kirbytext() ?></h1>
            <?php echo $page->text()->kirbytext() ?>
    	
            <div class="row row-fix kontaktbereich">
    	     <div class="col-lg-6 col-md-6">
             <?php foreach($faq_list as $faq_entry): $i++ ?>
    			
    			<h1><?php echo $faq_entry->frage() ?></h1>
    			<div class="antwort"><?php echo $faq_entry->antwort() ?></div>
             <?php endforeach ?>
    	
    	     </div>
    	     <div class="col-lg-6 col-md-6 adresse"><?php echo $page->hinweis()->kirbytext() ?></div>
    	    </div>
         </div>
       </div>
    	<?php snippet('footer') ?>
      </main>

I suppose you want to use the $i variable for that? Then you need to echo it where you want it:

<div class="faq-<?php echo $i ?>"></div>

works. THANK U texnixe