I tried to extend columns with but couldnt achive.
According to document:
Fields, sections, tabs and entire blueprint layouts can be reused within your blueprints.
Fields, sections, tabs and entire blueprint layouts can be reused within your blueprints. If you want, you can even create a complete component system to apply to multiple projects.
Did I misunderstand?
Here my blueprints:
site.yml
title: Site
columns:
left:
width: 1/2
sections:
# sections
right:
width: 1/2
sections:
# sections
extends: sections/site
sections/site.yml
customLeft:
width: 1/2
sections:
# sections
customRight:
width: 1/2
sections:
# sections
In above sample, extended elements do not appear and no any error.
You can extend a single column, but not columns in general, I think.
columns:
customcol:
extends: columns/costumcol
Or you can extend a complete layout, no matter if it contains tabs or columns.
/**
* Normalizes all required props in a column setup
*
* @param string $tabName
* @param array $columns
* @return array
*/
protected function normalizeColumns(string $tabName, array $columns): array
{
foreach ($columns as $columnKey => $columnProps) {
if (is_array($columnProps) === false) {
continue;
}
$columnProps = $this->convertFieldsToSections($tabName . '-col-' . $columnKey, $columnProps);
// inject getting started info, if the sections are empty
if (empty($columnProps['sections']) === true) {
$columnProps['sections'] = [
$tabName . '-info-' . $columnKey => [
'headline' => 'Column (' . ($columnProps['width'] ?? '1/1') . ')',
Hmm, you right. I checked the about line and will not work
I just wanted to customize some of the template (user defined dynamic theme)
Thank you so much, i’ll try complete layout that used it before.
You can even get pretty creative:
site/columns/customcols.yml
columns:
maincol:
width: 2/3
sections:
menusection:
type: fields
fields:
menu:
type: structure
fields:
level1entry:
type: pages
level2:
type: structure
fields:
level2entry:
type: pages
comments:
type: pages
parent: kirby.page("comments")
create: comment
template: comment
aside:
width: 1/3
sections:
notes: sections/notes
pages:
type: pages
create: default
template:
- about
- home
- default
Version 1 site.yml: Unset columns and sections within columns
title: Site
extends: columns/customcols
columns:
maincol: false
aside:
sections:
pages: false
Version 2 site.yml: Unset sections within columns
title: Site
extends: columns/customcols
columns:
maincol:
sections:
menusection: false
aside:
sections:
notes: false
Version 3 site.yml: Extend the aside column with a new section
title: Site
extends: columns/customcols
columns:
aside:
extends: aside
sections:
info:
type: info
text: Some text
Or extend the sections within and so on…
1 Like
I’m a little ambitious
I solved this issue with adding just one line to Cms/Blueprint.php
file.
Can we add such a feature? And may I ask your review?
It would be a nice feature to extends the columns as well
Solution
Adding following line:
$columns = $this->extend($columns);
Before the foreach loop in 381. line:
/**
* Normalizes all required props in a column setup
*
* @param string $tabName
* @param array $columns
* @return array
*/
protected function normalizeColumns(string $tabName, array $columns): array
{
foreach ($columns as $columnKey => $columnProps) {
if (is_array($columnProps) === false) {
continue;
}
$columnProps = $this->convertFieldsToSections($tabName . '-col-' . $columnKey, $columnProps);
// inject getting started info, if the sections are empty
if (empty($columnProps['sections']) === true) {
$columnProps['sections'] = [
$tabName . '-info-' . $columnKey => [
I can PR if you want me to, but I’m not very good at unit tests.
I can’t review this and have to leave this to the devs.
Ok, should I add kirby ideas to review?
Yes, it’s an ideas issue. You can of course create a PR but they usually want unit tests.
Although I wonder what would be the advantage since we have all the options I mentioned above? You can even add additional columns:
title: Site
extends: columns/customcols
columns:
newcol:
width: 1/1
sections:
newsec:
type: info
text: Some other text
This will give you everything in customcols + the additional newcol column
So the only difference would be the position of the extends
directive.
You right! But with this way only for CUSTOM + BASE
.
With extending columns feature user design unlimited layouts.
CUSTOM + BASE
BASE + CUSTOM
CUSTOM + CUSTOM + BASE
CUSTOM + BASE + CUSTOM
For example i need in my prod website like that (User Defined Layout):
In the solution I found there is a bug like putting all the columns on top like your solution but devs will already review and test.
Best solution is Version 3 site.yml: Extend the aside column with a new section
for now
I gave you trouble again
In addition, we cannot extend/reuse multiple sections like that:
default.yml
column:
left:
width: 1/2
extends: sections/custom
sections/custom.yml
sections:
# section01
# section02
# section03