Label blueprint children


How to reach the blueprint of a subpage?

For example when I am on my parent page I do:

$field = page()->blueprint()->field('text');

From the parent page, can I retrieve the blueprint label of a field from my child pages?

Try this one:

$field = $page->children()->first()->blueprint()->field('text');


$field = page('blog')->children()->first()->blueprint()->field('text');
1 Like

Good morning ahmetbora,
it works !

Now that I have displayed the field label.
I would like to display the data of the following field

            label: mylabel
            type: tags
            options: query
            query: site.index.pluck("myfield", ",", true)

Thank you

Like that:

echo $page->children()->first()->myfield();



For loop:

$subpages = $page->children();
$field    = $subpages->first()->blueprint()->field('myfield');

foreach ($subpages as $child) {
  <?= $field['label'] ?>: <?= $child->myfield() ?>


I adapted it to display the data rather than the label.

  $subpages = $page->children()->listed();
  $field    = $subpages->first()->blueprint()->field('myfield');

  foreach ($subpages as $option): ?>
    <?= $option->myfield(); 



On the other hand, how to filter the display only once? Because it repeats the duplicate texts.

I looked at filterBy() or pluck() but I don’t understand how to go about it. It may be something else.

You want to show all tags of all subpages one liner?

Tags: subpage-a-tag, subpage-b-tag, subpage-c-tag

with your code it displays the data well but as they are tags I would like not to display the doubles.

sample data:

Route Route Route Route Route Route Route Route Route Route Route Route Route Route Route, Gravel, Critérium Route Route Route Route ttttt

Which corresponds to about 20 child pages (where you see commas it means that there are several tags).

I would like this to come out:
Route, Gravel, Critérium, ttttt

Because I’m going to integrate it into a form. Then I could list with checkboxes.

So you can use array_unique to avoid duplicate:

<?php echo implode(', ', array_unique($page->index()->pluck('myfield', ','))) ?>

Indeed it is easier with $page->index()

I just looked at the documentation, I did not know!

thank you, I put my final code as soon as I finished.

I thought I could do it.

I put a foreach but it loops the unique tags several times.

I don’t understand how to display a single data in each checkbox:

<input type="checkbox" id="value1" name="value1" value="value1">

As far as I understand, you can loop without using implode like that:

<?php $tags = array_unique($page->index()->pluck('myfield', ',')); ?>
<?php foreach ($tags as $tag): ?>
    <?= $tag ?>
    <input type="checkbox" value="<?= $tag ?>">
<?php endforeach ?>

Instead of using array_unique, you can pass a third param to pluck:

$page->index()->pluck('myfield', ',', true)
1 Like

I did this:

I display the name of the blueprint in the header.

Then, for the loop I copied the code from @ahmetbora which is great!

                  $discipline_label = $page->children()->first()->blueprint()->field('discipline')['label'];

                <div class="form-group">
                <p for="discipline" class="mb-0">Discipline <abbr title="required">*</abbr></p>                
                  <?php foreach(array_unique($page->index()->pluck('discipline', ',')) as $tag): ?>
                    <div class="form-check form-check-inline">
                      <input class="form-check-input" type="checkbox" id="discipline" name="discipline" value="<?= $tag ?>">
                      <label class="form-check-label" for="flexCheckDefault">
                        <?= $tag ?>
                  <?php endforeach ?>

Only last problem.

If I check only one box everything is fine.
If I tick 2 boxes, it registers me only one box.
In the content file, a comma is expected between each data.

The best is to make a condition?

Multiple checkboxes need to be sent as array

<input class="form-check-input" type="checkbox" id="discipline" name="discipline[]" value="<?= $tag ?>">

It’s all good, thanks to you 2, everything works!