Creating a variable from a field in blocks

Hello, my company had their website designed by an external agent. I have been given the role to administer the website for changes. As the apprentice and with very little Kirby experience i’m having some small problems along the way.

I have some questions as i would like to expand our website to create a job market page for our positions and then send them to our application software (prescreen).

Our website was created with blocks, however I would like to take a piece of information from the block, (i’m guessing a string) to use on a child page of the careers page.

In the .txt file I have the following information that i would like to extract and use elsewhere

Screenshot 2021-10-07 153059

I want to take the “position” of the job and use it on the application page of the website(the child of the job listing page where this is found)

is this possible? does anyone have any tips on how i could do this?

also another question…

is it possible for Kirby to create a new child page automatically or do I have to always do it manually in the panel?

For example… If I created a new block for a new position in our company and gave it a reference number of 111654 in the panel of my custom block. can Kirby create a new URL www.mysite.com/careers/apply/111654

I already have a template for “apply” it would just take the position and include it in the template. Whether it is the refence number or job title isn’t really important just if it is at all possible.

If anyone has created a small job market (Jobbörse) for their website with kirby i would be very thankful with any tips or help

Could you provide more details about the block? Maybe post the blueprint with the types of block used and if you have custom blocks then the blueprint of the custom block.

Yes, that would be possible via a hook when you save the page (page.update:after hook: page.update:after | Kirby CMS). You would have to check if the page already exists and if not, create a new page.

Here is the blueprint to the custom block and i’ve also included the snippet to the block as well.

name: Neue Ausschreibungen
icon: users
tabs:
  careers:
    label: Ausschreibungen
      fields:
        reference:
          label: Job ID
          type: number
          required: true
          width: 2/6
        position:
          label: Name/Position
          type: text
          required: true
          width: 4/6
        location:
          label: Ort
          type: text
          required: true
          width: 2/6
        text:
          label: Einleitung
          type: writer
          inline: true
          marks:
            - bold
            - italic
            - url
        tasks_headline:
          label: Überschrift der Aufgabensektion
          type: text
          required: true
          placeholder: Deine Aufgaben
          width: 1/2
        competences_headline:
          label: Überschrift der Kompetenzsektion
          type: text
          required: true
          placeholder: Deine Kompetenzen
          width: 1/2
        tasks:
          label: Aufgaben
          type: list
          required: true
          width: 1/2
          inline: true
        competences:
          label: Kompetenzen
          type: list
          required: true
          width: 1/2
          inline: true

  cta:
    label: Call to Action
    fields:
      cta_headline:
        label: Überschrift
        type: writer
        inline: true
        marks: false
        placeholder: Haben wir Dein Interesse geweckt?
        required: true
      cta_description:
        label: Text
        type: writer
        inline: true
        marks:
          - link
          - italic
          - bold
      cta_button:
        label: Button
        type: text
      cta_buttonlink:
        label: Button-Link
        type: link
        settings: false
<?php

/** @var \Kirby\Cms\Block $block */ ?>

<section class="careers">
  <div class="container">
  <ul class="joblist">
    <?php
    $jobs = $block->careers()->toStructure();

    foreach ($jobs as $job) : ?>
      <li class="joblisting">
        <details>
          <summary>
            <h3><?= $job->position() ?><?php e($job->location()->isNotEmpty(), ' — ' . $job->location()) ?></h3>
          </summary>
          <div class="jobcontent">
            <div class="jobdetails">
              <p hidden><?= $job->reference()</p>
              <p><?= $job->text() ?></p>
              <div class="list">
                <h4><?= $job->tasks_headline() ?></h4>
                <?= $job->tasks() ?>
              </div>
              <div class="list">
                <h4><?= $job->competences_headline() ?></h4>
                <?= $job->competences() ?>
              </div>
            </div>
            <aside class="cta">
              <h4><?= $block->cta_headline() ?></h4>
              <p><?= $block->cta_description() ?></p>
              <?php $link = $block->cta_buttonlink()->toLinkObject() ?>
              <a href="<?= $link->href() ?>">
                <button class="chatcta"><?= $block->cta_button() ?></button>
              </a>
            </aside>
          </div>
        </details>
      </li>
    <?php endforeach ?>
  </ul>
</div>
</section>

Sorry, I missed your answer.

On saving the page, in your hook you could filter your blocks field by this custom block, then filter them by pages that already exists. Then loop through the remaining custom blocks and create a new page.