$layouts
A collection of layouts
- $layouts->add()
- $layouts->append()
- $layouts->chunk()
- $layouts->clone()
- $layouts->count()
- $layouts->current()
- $layouts->data()
- $layouts->empty()
- $layouts->extend()
- $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->indexOf()
- $layouts->intersection()
- $layouts->intersects()
- $layouts->isEmpty()
- $layouts->isEven()
- $layouts->isNotEmpty()
- $layouts->isOdd()
- $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->pluck()
- $layouts->prepend()
- $layouts->prev()
- $layouts->query()
- $layouts->random()
- $layouts->remove()
- $layouts->rewind()
- $layouts->search()
- $layouts->set()
- $layouts->shuffle()
- $layouts->slice()
- $layouts->sort()
- $layouts->sortBy()
- $layouts->toArray()
- $layouts->toBlocks()
- $layouts->toJson()
- $layouts->toString()
- $layouts->valid()
- $layouts->values()
- $layouts->when()
- $layouts->without()
- Layouts::factory()
- Layouts::parse()
- Layouts::sortArgs()
- new Layouts()
How to render layouts in templates?
Using the toLayouts
field method, you can retrieve a Layouts collection - a collection of Kirby\Cms\Layout
objects:
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)
:
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.
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.