$layouts
A collection of layouts
- 
		
			new Layouts()
 - 
		
			$layouts->add()
 - 
		
			$layouts->append()
 - 
		
			$layouts->chunk()
 - 
		
			$layouts->clone()
 - 
		
			$layouts->count()
 - 
		
			$layouts->current()
 - 
		
			$layouts->data()
 - 
		
			$layouts->empty()
 - 
		
			$layouts->extend()
 - 
		
			Layouts::factory()
 - 
		
			$layouts->field()
 - 
		
			$layouts->filter()
 - 
		
			$layouts->filterBy()
 - 
		
			$layouts->find()
 - 
		
			$layouts->findBy()
 - 
		
			$layouts->findByKey()
 - 
		
			$layouts->first()
 - 
		
			$layouts->flip()
 - 
		
			$layouts->get()
 - 
		
			$layouts->getAttribute()
 - 
		
			$layouts->getIterator()
 - 
		
			$layouts->group()
 - 
		
			$layouts->groupBy()
 - 
		
			$layouts->has()
 - 
		
			$layouts->hasBlockType()
 - 
		
			$layouts->hasMethod()
 - 
		
			$layouts->indexOf()
 - 
		
			$layouts->intersection()
 - 
		
			$layouts->intersects()
 - 
		
			$layouts->isEmpty()
 - 
		
			$layouts->isEven()
 - 
		
			$layouts->isNotEmpty()
 - 
		
			$layouts->isOdd()
 - 
		
			$layouts->join()
 - 
		
			$layouts->key()
 - 
		
			$layouts->keyOf()
 - 
		
			$layouts->keys()
 - 
		
			$layouts->last()
 - 
		
			$layouts->limit()
 - 
		
			$layouts->map()
 - 
		
			$layouts->next()
 - 
		
			$layouts->not()
 - 
		
			$layouts->nth()
 - 
		
			$layouts->offset()
 - 
		
			$layouts->paginate()
 - 
		
			$layouts->pagination()
 - 
		
			$layouts->parent()
 - 
		
			Layouts::parse()
 - 
		
			$layouts->pluck()
 - 
		
			$layouts->prepend()
 - 
		
			$layouts->prev()
 - 
		
			$layouts->query()
 - 
		
			$layouts->random()
 - 
		
			$layouts->remove()
 - 
		
			$layouts->rewind()
 - 
		
			$layouts->search()
 - 
		
			$layouts->set()
 - 
		
			$layouts->shuffle()
 - 
		
			$layouts->slice()
 - 
		
			$layouts->sort()
 - 
		
			Layouts::sortArgs()
 - 
		
			$layouts->sortBy()
 - 
		
			$layouts->toArray()
 - 
		
			$layouts->toBlocks()
 - 
		
			$layouts->toJson()
 - 
		
			$layouts->toString()
 - 
		
			$layouts->update()
 - 
		
			$layouts->valid()
 - 
		
			$layouts->values()
 - 
		
			$layouts->when()
 - 
		
			$layouts->without()
 
How to render layouts in templates?
Using the toLayouts field method, you can retrieve a Layouts collection - a collection of Kirby\Cms\Layout objects:
<?php foreach ($page->layout()->toLayouts() as $layout): ?>
<section class="grid" id="<?= $layout->id() ?>">
  <?php foreach ($layout->columns() as $column): ?>
  <div class="column" style="--span:<?= $column->span() ?>">
    <div class="blocks">
      <?= $column->blocks() ?>
    </div>
  </div>
  <?php endforeach ?>
</section>
<?php endforeach ?>
Calculate the column span value
Each column in a layout has a $column->width() method which will return the width defined in the blueprint. (i.e. 1/2) but for many grid systems you need to know how many columns the current column should span in the grid. This can be done with the $column->span() method. The method calculates with a 12-column grid by default. So for example, if your column width is 1/2 the span method would return a value of 6. If you are working with a different kind of grid system you can pass the number of columns like this: $column->span(6):
<?php foreach ($page->layout()->toLayouts() as $layout): ?>
<section class="6-column-grid" id="<?= $layout->id() ?>">
  <?php foreach ($layout->columns() as $column): ?>
  <div class="column" style="--span:<?= $column->span(6) ?>">
    <div class="blocks">
      <?= $column->blocks() ?>
    </div>
  </div>
  <?php endforeach ?>
</section>
<?php endforeach ?>
Working with individual blocks
In some cases, you might even want to controll the way blocks within layouts are rendered. $column->blocks() will return a blocks collection that you can work with and create another nested foreach loop.
<?php foreach ($page->layout()->toLayouts() as $layout): ?>
<section class="6-column-grid" id="<?= $layout->id() ?>">
  <?php foreach ($layout->columns() as $column): ?>
  <div class="column" style="--span:<?= $column->span(6) ?>">
    <div class="blocks">
      <?php foreach ($column->blocks() as $block): ?>
      <div class="block block-type-<?= $block->type() ?>">
        <?= $block ?>
      </div>
      <?php endforeach ?>
    </div>
  </div>
  <?php endforeach ?>
</section>
<?php endforeach ?>
Passing the layout object to the block snippet
If you need to access the layout object in a block snippet, you need to pass it to the snippet manually.
<?php foreach ($page->layout()->toLayouts() as $layout): ?>
<section class="6-column-grid" id="<?= $layout->id() ?>">
  <?php foreach ($layout->columns() as $column): ?>
  <div class="column" style="--span:<?= $column->span(6) ?>">
    <div class="blocks">
      <?php foreach ($column->blocks() as $block): ?>
      <div class="block block-type-<?= $block->type() ?>">
        <?php snippet('blocks/' . $block->type(), ['block' => $block, 'layout' => $layout]) ?>
      </div>
      <?php endforeach ?>
    </div>
  </div>
  <?php endforeach ?>
</section>
<?php endforeach ?>