degoya
December 22, 2021, 12:17pm
1
i’d like to build a Panel Plugin for Kirby 3.5.8.
How i can add props to the index.php and read them from the index.js?
in my index.php i’ve got the following code:
Kirby::plugin('degoya/myplugin', [
'fields' => [
'myplugin' => [
'props' => [
'website' => 'https://google.com',
],
],
],
the index.js looks like this
import View from "./components/View.vue";
panel.plugin("degoya/myplugin", {
views: {
myplugin: {
label: "MyPlugin",
icon: "bolt",
component: View,
},
},
});
in my Vue file i got
export default {
props: {
website: String,
},
and use {{ website }} and get an empty result
anyone can point me to a solution?
texnixe
December 22, 2021, 1:21pm
2
In your index.js, you are creating a view instead of a field, while in your index.php, you have a field.
degoya
December 22, 2021, 1:42pm
3
thanks for your reply, but the link only shows how to make a field plugin or did i missed something?
could you please point me how to use props with a view.
using the following doesn’t worked for me
Kirby::plugin('degoya/myplugin, [
'views' => [
'myplugin' => [
'props' => [
in Kirby 3.6 it works like this:
Kirby::plugin('degoya/myplugin', [
'areas' => [
'myplugin' => function ($kirby) {
return [
'label' => 'myPlugin',
'link' => 'myplugin',
'menu' => true,
'icon' => 'bolt',
'views' => [
[
'pattern' => 'myplugin',
'action' => function () {
return [
'component' => 'myplugin',
'title' => 'myPlugin',
'props' => [
'website' => 'https://google.com',
],
];
}
]
]
];
}
],
texnixe
December 22, 2021, 1:50pm
4
You are in the 3.6 docs, docs for 3.5 are here:
Docs: Panel views | Kirby CMS
Recipe: My first Panel view | Kirby CMS