Permissions for a role within the field

Hi Community and Support Team :v:!

I have a field of type select inside my Kirby version 3.6.5 panel.

Which I only want to be able to edit a user of type admin.

How can I delimit that condition within a field in my blueprint.


positions:
  label: Positions for employees within the company
  type: tags
  help: For example: Financial Advisor, Manager, etc.

I await your response and help please.

Thank you very much.

Regards!

You would have to create the blueprint dynamically, see Programmable blueprints | Kirby CMS

You can do this on a blueprint or per field basis.

1 Like

Hi @texnixe !

Ok, thank you very much for your answer and help. I will review the information you share with me.

Thank you very much.

Regards!

Hi @texnixe!

I am trying to create a Programmable blueprint from my plugins folder. But the blueprint for my cards page is not recognizing me.

** To use this blueprint, remove the original file**

site/blueprints/pages/cards.yml

Plugins:

site/plugins/programmable-blueprints/

Load different blueprints per use:

site/plugins/programmable-blueprints/index.php

Code:

<?php

use Kirby\Cms\App as Kirby;

Kirby::plugin('cookbook/programmable-blueprints', [
	'blueprints' => [
		'pages/cards' => function($kirby) {
			if (($user = kirby()->user()) && $user->isAdmin()) {
				return Data::read(__DIR__ . '/blueprints/pages/cards.admin.yml', 'yaml');
			}else{
				return Data::read(__DIR__ . '/blueprints/pages/cards.editor.yml', 'yaml');
			}
		}
	],
]);

?>

Blueprint file for admin

site/plugins/programmable-blueprints/blueprints/pages/cards.admin.yml

Blueprint file for editor

site/plugins/programmable-blueprints/blueprints/pages/cards.editor.yml

Thank you very much.

Regards!

The path is wrong, the files should either be in a subfolder

site/plugins/programmable-blueprints/blueprints/pages/

Or you have to change the path for Data::read.

Hi @texnixe !

OK perfect.

It was a mistake on my part in my forum post but I have already edited my post.

If I have my correct routes within my project but the blueprint does not load correctly.

Blueprint file for admin

site/plugins/programmable-blueprints/blueprints/pages/cards.admin.yml

Blueprint file for editor

site/plugins/programmable-blueprints/blueprints/pages/cards.editor.yml

I await your response and help please.

Thank you very much.

Regards!

That should work. What is the result vs the expected result? Have you made sure to remove your original cards.yml from /site/blueprints/pages?

Please post your cards.admin.yml and cards.editor.yml.

Hi @texnixe !

Giving follow-up and conclusion to this issue.

All the code is correct, except for a mistake on my part in the path.

I was using the content folder, but I have to use the template name.

:x: Error code:

<?php

use Kirby\Cms\App as Kirby;

Kirby::plugin('cookbook/programmable-blueprints', [
	'blueprints' => [
		'pages/cards' => function($kirby) {
			// Code
		}
	],
]);

?>

:white_check_mark: Correct code:

<?php

use Kirby\Cms\App as Kirby;

Kirby::plugin('cookbook/programmable-blueprints', [
	'blueprints' => [
		'pages/templatename' => function($kirby) {
			// Code
		}
	],
]);

?>

Thank you very much.

regards