M_G
September 8, 2022, 9:30am
1
Hey.
I’m trying to load a based on a user role a site.yml (site/blueprints/site.yml)
Maybe I’m doing something wrong? But my test user in this role see the normal site.yml
My code:
site/plugins/role-blueprints/index.php
<?php
if(($user = kirby()->user()) && $user->role()->name() === 'coach') {
$dir = __DIR__ . '/blueprints/pages/roles/site-coach.yml';
} else {
$dir = __DIR__ . '/blueprints/site.yml';
}
Kirby::plugin('page/role-blueprints', [
'blueprints' => [
'site' => $dir
]
]);
site/blueprints/users/coach.yml
title: Coach
site/blueprints/pages/roles/site-coach.yml
title: Site
columns:
- width: 1/3
sections:
pages:
headline: Pages
type: pages
templates:
- ressourcen
sortable: true
storage/accounts/pOfj83Wh/index.php
<?php
return [
'email' => 'test@test.com',
'language' => 'de',
'name' => 'Coach',
'role' => 'Coach'
];
texnixe
September 8, 2022, 11:10am
2
Have you removed the site.yml from /site/blueprints?
luca
September 8, 2022, 11:22am
3
Guessing from your post on discord , you put your blueprints in the wrong folder.
You have to put them inside the plugin folder, not inside /site/blueprints.
texnixe
September 8, 2022, 11:24am
4
Please guys, this is really a waste of time of you always post in two places without any references.
2 Likes
M_G
September 8, 2022, 12:33pm
5
Why removing?
I have one in
$dir = DIR . ‘/blueprints/site.yml’;
and one in
$dir = DIR . ‘/blueprints/pages/roles/site-coach.yml’;
Do i miss there somehting?
M_G
September 8, 2022, 12:41pm
6
I tried - don’t work for me.
if(($user = kirby()->user()) && $user->role()->name() === 'coach') {
$dir = __DIR__ . '/blueprints/site-coach.yml';
} else {
$dir = __DIR__ . '/blueprints/site.yml';
}
Kirby::plugin('website/role-blueprints', [
'blueprints' => [
'site' => $dir
]
]);
Also that don’t work for me
M_G
September 8, 2022, 12:54pm
7
Ah now it is working.
I put both in the plugin folder @luca thanks for the hint