Pages and layout
A page is a list of blocks: sections, grids, tabs, tables, forms, metrics. Each user gets only the blocks of resources they may view; a container left empty disappears.
php
class OverviewPage extends Page
{
public const NAME = 'overview';
public const LABEL = 'Overview';
public function layout(): array
{
return [
Block::section(
[Block::table('products', filters: ['status' => 'draft'], actions: ['reprice'])],
label: 'Drafts',
description: 'Products waiting to be published.',
),
Block::grid([
Block::section([Block::table('categories')], label: 'Categories'),
Block::section([Block::table('suppliers')], label: 'Suppliers'),
], columns: [1, 2]),
Block::tabs([
Block::tab('Published', [Block::table('products', filters: ['status' => 'published'])]),
Block::tab('Archived', [Block::table('products', filters: ['status' => 'archived'])]),
Block::tab('Suppliers', [Block::table('suppliers')]),
]),
];
}
}Grid columns
| Code | Result |
|---|---|
Block::grid($children) | one row, a column per child |
Block::grid($children, columns: 4) | 4 equal columns, children wrap |
Block::grid($children, columns: [2, 10]) | one row, a weight per child: 2/12 and 10/12 |
When a user may not see a child, its weight goes with it and the row stays full. On narrow screens every block takes the whole row.